简体   繁体   English

建立与SQL Server的连接时出错

[英]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.

相关问题 与sql server建立连接时出错 - error while establishing connection with sql server 与SQL Server 2008建立连接 - Establishing connection with SQL Server 2008 在WPF应用程序中建立与SQL Server的连接时出错 - Error while establishing connection to SQL Server in WPF application ADO.NET:建立与SQL Server的连接时发生错误 - ADO.NET : Error occurred while establishing a connection to SQL Server SQL服务器建立连接时出错 - Error occured during establishing connection between SQL Server 程序连接到服务器但报告-建立SQL连接时出错 - Program connect to server but report - error while establishing a sql connection 如何超时“建立与SQL Server的连接时发生与网络有关或特定于实例的错误”错误 - How to timeout “A network-related or instance-specific error occurred while establishing a connection to SQL Server” error "出现错误:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误" - Getting error: A network-related or instance-specific error occurred while establishing a connection to SQL Server 安装的WinForm应用程序抛出错误“建立与SQL Server的连接时发生网络相关或实例特定的错误” - Installed WinForm App throws error “a network related or instance specific error occurred while establishing a connection to sql server” 得到错误“与SQL Server建立连接时发生与网络相关或特定于实例的错误…” - Getting error “A network-related or instance-specific error occurred while establishing a connection to SQL Server…”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM