我正在使用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