【发布时间】:2018-08-04 09:58:33
【问题描述】:
private void frmResibo_Load(object sender, EventArgs e)
{
market m = new market();
string cs = @"Data Source =.localhost; Initial Catalog = thesisdb; User ID=root; Integrated Security = true";
SqlConnection cn = new SqlConnection(cs);
SqlDataAdapter da = new SqlDataAdapter("select * from tbl_itemlist", cn);
da.Fill(m, m.Tables[0].TableName);
ReportDataSource rds = new ReportDataSource("tbl_itemlist", m.Tables[0]);
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(rds);
this.reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();
}
我在"da.Fill--- 行中遇到这样的错误
System.Data.SqlClient.SqlException: '建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供者:命名管道提供者,错误:40 - 无法打开与 SQL Server 的连接)'
【问题讨论】:
-
您正在使用 C# SQL-server 客户端连接到 MySQL 服务器。 google.nl/search?q=C%23+mysql
-
你需要安装mysql连接器并且需要使用它的dll。连接类将是 MySQLConnection
-
你也缺少 con.open()
-
我尝试放置 con.Open() 但仍然出现错误,也尝试使用 MySQLConnecting 并且仍然相同。请帮忙
-
Data Source =.localhost我想你只是想要localhost但My SQL Server非常模糊......System.Data.SqlClient是为 Microsoft SQL Server 的。