我正在使用SQL Server。我曾经通过所有连接:SQL Server的连接字符串?
SqlConnection con = new SqlConnection("data source = .; database = xyzDatabase; integrated security = true");//developed with developer edition.
现在我想运行我的SQL Server Express应用程序,所以我用这个:
SqlConnection con = new SqlConnection("data source = .\\sqlexpress; initial catalog = xyzDatabase; user id = sa; password = 123");
一点要记住的是,我在运行时创建我xyzDatabase
形成加载事件。但是当我执行程序时,出现以下错误:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)
不** ** EVER **使用'sa'帐户 - ** N-E-V-E-R **!要么使用集成安全性,要么为你的应用程序使用**明确的**用户。 – 2013-03-06 09:57:10
与mssql ide,您可以登录并更改sqlexpress的安全性。 – 2013-03-06 10:03:36