[英]Error establishing connection to SQL Server
I just started creating a local database in Visual Studio for the first time and I'm having a hard time making it work. 我刚刚开始在Visual Studio中创建一个本地数据库,而且我很难让它工作。
In modify connection I tested and it works and also got the connection string: 在我测试的修改连接中它起作用并且还获得了连接字符串:
string ConnectionString = @"Data Source=D:\Bratulescu Mihai\WindowsFormsApplication1\WindowsFormsApplication1\NodeBDatabase.sdf";
sqlConn = new SqlConnection(ConnectionString);
sqlConn.Open();
But when it tries Open() it cannot connect. 但是当它尝试Open()时它无法连接。 I don't know much about this whole server thing, I just created the db and it's DataSet.
我对整个服务器的事情了解不多,我刚创建了db和它的DataSet。
If you are using SQLCe
since I see you are reffering to an sdf
file you should add a reference of System.Data.SqlServerCe
and try: 如果您使用的是
SQLCe
因为我发现您正在访问sdf
文件,您应该添加System.Data.SqlServerCe
的引用并尝试:
using System.Data.SqlServerCe;
....
sqlConn = new SqlCeConnection(ConnectionString);
sqlConn.Open();
are you sure about the connection string? 你确定连接字符串? You could take a look at this site: http://www.connectionstrings.com/sql-server-compact/
你可以看看这个网站: http : //www.connectionstrings.com/sql-server-compact/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.