Tag: mysql

将MySQL连接到Visual Studio C#

我正在尝试编写数据访问代码以将MySQL连接到visual studio。 到目前为止我有这个代码,但我不知道它是否正确。 我正在使用我的书并注释了其他一些东西,但是当我收录已注释的信息时,我收到了错误。 public static MySqlConnection getconnection() { string connectionstring = “serve=r127.0.0.1; uid = root;” + “pwd = databasses; database = group1;” MySqlConnection connection = new MySqlConnection(connectionstring); return connection; } 注释掉的信息: //string connectionstring = “Data Source=localhost\\MySql;Initial Catalog = group1; Integrated Security=True”; and //conection.Open(); 我有办法检查我的连接是否已建立? 我能够运行它并显示一个空白表格,但我担心这是错误的。

如何发布c#window应用程序安装程序

我正在尝试发布C#Windows应用程序。 我试图安装shield和visual studio安装程序,但它无法正常工作。 此设置只能安装在安装了Visual Studio的笔记本电脑或PC上。 任何人都可以帮助我需要什么先决条件以及如何发布安装程序setup.exe app.config连接字符串SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings [“connection_string”]。ConnectionString); 但它发生错误无法更新数据库,因为数据库是只读的visual studio

无法将MySQL查询转换为LINQ

我已经看过这个解决方案,但我的问题仍然存在。 我无法将MySQL查询转换为LINQ 。 我正在使用LinqPad 。 我创建了一个连接。 执行了我的查询并得到了结果。 但是lambda部分是空的。 SELECT * FROM ( SELECT @row := @row +1 AS rownum, zdjh,sjsj ,xhqd FROM ( SELECT @row :=0) r, `tj_xhqd` ORDER BY sjsj ) ranked WHERE rownum % 24= 0 AND zdjh = ‘002999001180’ AND sjsj>=’2018-02-24 08:38:11′ 我想将其转换为LINQ 。 型号名称为kesc 更新1 我试图将我的MySQL转换为LINQ 。 var mainDetails = kesc.tj_xhqd.Where(m […]

如何从两个表中获得Sum?

我有两个表,第一个名称是“sales”,第二个名称是“items”,两个表中都有相同的列“code”和“qtd”; 我想写MYSQL查询,我需要来自两个表中代码相同的表的sum(qtd)。 单表我正在使用这个 “按代码从销售组中选择代码,总和(qtd)”;

流畅的NHibernate无法在测试的调试模式下从GAC加载MySql.Data

我得到以下代码: var cfg = new Configuration(); cfg.Configure(); FluentConfiguration config = Fluently.Configure(cfg) .Mappings( m => m.FluentMappings.AddFromAssemblyOf()); s_SessionSource = new SessionSource(config); 当我使用以下错误调试unit testing时,最后一行抛出exception: 无法加载文件或程序集“MySql.Data”或其依赖项之一。 该系统找不到指定的文件。 问题是它没有说它尝试使用的版本。 我尝试使用以下配置捕获所有版本: 但问题仍然存在。 奇怪的是exception没有说明版本,它通常在这种情况下。 流利的NHB是3.1版本的最新1.2版NHB是3.2连接器是6.3.7.0 我正在使用MSTest。 当我在没有调试的情况下运行测试(运行检查测试)时,它不会抛出任何exception并成功完成(它确实对MySQL测试数据库执行操作,因此在这种情况下它会找到MySql.Data.dll并插入行例如没有问题) 。 更新好的,当我从GAC获取MySql.Data.dll并将其作为文件引用时,并设置Copy Local它最终开始在调试中工作。 怎么回事? 为什么它无法在调试中从GAC加载它,并且可以在简单的运行模式下?

连接到OpenShift(Redhat Paas)的mysql实例

我正在尝试将我的c#应用程序与openshift数据库连接起来。 但是我在conn.Open()上得到了这个例外 Eccezione => MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. in MySql.Data.MySqlClient.NativeDriver.Open() in MySql.Data.MySqlClient.Driver.Open() in MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) in MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() in MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() in MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() in MySql.Data.MySqlClient.MySqlPool.GetConnection() in MySql.Data.MySqlClient.MySqlConnection.Open() 这是我的方法: public void connect() { string connStr = @”Server=test-lound.rhcloud.com;Port=3306;Database=test;Uid=XXXX;Pwd=YYYY;”; MySqlConnection conn = new MySqlConnection(connStr); try { Console.WriteLine(“Connecting to MySQL…”); conn.Open(); Console.WriteLine(“Connection successfull […]

SQLDependency等效于MySQL

我想在我的ASP.net项目上实现实时更新,所以我试图实现长轮询机制和Comet。 var isPolling = 0; function longPolling() { isPolling++; $.ajax({ type: “GET”, url: “CometAsyncHandler.ashx?waitTime=60”, // one minute //async: true, cache: false, //timeout:12000, success: function(data){ isPolling–; if(data == “NEWDATAISAVAILABLE”) RefreshData(); // this function is generated by using RegisterFunctionToPostBack() else if( data == “TOOLONG-DOITAGAIN” ) setTimeout(“longPolling()”, 0 ); else addLongPollingError(“error”, “Error on server side. Received data: \”” […]

C#对SSPI的调用失败,请参阅内部exception – 无法联系本地安全机构

我写了一个C#程序来连接MySql服务器和’ Mysql Connector / Net ‘。 我使用ssl选项的安全连接。 我太正确地制作了服务器证书和客户端pfx证书。 但是当我试图连接到服务器时,我得到了这个例外。 System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. —> System.ComponentModel.Win32Exception: The Local Security Authority cannot be contacted — End of inner exception stack trace — at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at […]

Datagridview单元格值更改更新数据库

我已经将Mysql数据库中的数据检索到DataGridView1中。 让我们假设我在第0行。当我更改第0行,单元格1的内容并按回车键或按钮时,更新查询应修改该行,但我无法修改单元格的值。 当我重新加载数据并且未修改数据库时,单元格保持其先前的值。 例如,如果我将Client_Name列下的单元格内容从“Acs”更改为“Gmt”,如何将单元格的值从“Acs”更改为“Gmt”? 并将其更新到Mysql数据库中,我在Vs 2012中使用c#。下面是我的代码,它将我的数据库检索到datagridview1,欢迎任何帮助谢谢。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data; using MySql.Data.MySqlClient; using System.Configuration; using System.Data.SqlClient; namespace PI.Gen { public partial class frmMain : Form { MySqlConnection Conn; public frmMain() { InitializeComponent(); btnDisconnect.Enabled = true; btnLoadData.Enabled = […]

如何在MySQL服务器和Microsoft SQL Server 2008中使用NHibernate

如何配置NHibernate连接MySQL服务器和Microsoft SQL Server 2008? 我确实想将数据从一台服务器复制到另一台服务器。 我听说过NHibernate的共享。