我在使用 c# System.Data.SqlClient 连接到我的本地数据库时遇到了一些问题。
信息:
- 数据库参数:名称:
baza
主机:localhost
实例:baza
端口:3306
架构:world
- 我的连接字符串:
@"server=localhost\baza;password=pass;User Id=root;database=world;Persist Security Info=True"
- 使用:c#、System.Data.SqlClient、MySQL Workbench
- 防火墙关闭
- 与 JDBC 成功连接,因此服务器正在工作
JDBC参数:
String url = "jdbc:mysql://localhost:3306/";
String driver = "com.mysql.jdbc.Driver";
String dbName = "world";
String username = "root";
String pass = "pass";
问题:
- 当我使用 conn.Open(); 这发生 =>(提供者:SQL 网络接口,错误:26 - 错误定位服务器/指定的实例)
试过:
- server=localhost 然后它给出 => 错误:40 - 无法打开到 SQL Server 的连接
- 许多其他愚蠢的组合,如 server=baza
- http://blogs.msdn.com/b/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx
- ASP.NET 初学者问题:如何摆脱这个错误?
- 与 freesql.org 服务器的连接也失败了
我不知道该怎么办...某事可能与服务器名称有关。
编辑:代码:
string connstr = @"Data Source=localhost\baza;password=qspass;User Id=root;"+
"Initial Catalog=world;Persist Security Info=True";
Console.WriteLine(connstr);
SqlConnection conn = new SqlConnection(conbuild.ConnectionString);
conn.Open();
Console.WriteLine("YO!");
Some more code...
从来没有达到过哟!:P