C#中连接字符串的正确结构

时间:2014-07-09 05:08:45

标签: c# sql-server-2008 connection-string

C#中连接字符串的正确结构应该是使用服务器的公共IP通过Internet访问SQL Server 2008 R2的? 我使用了以下连接字符串。它在我们的网络中使用本地IP工作正常,但当我试图通过互联网使用公共IP访问它时,我收到错误。

SqlConnection con = new SqlConnection("Data Source=tcp:192.168.0.16,49582;Initial Catalog=TrulyDB;uid=sa;pwd=sa@pass123;");

2 个答案:

答案 0 :(得分:0)

SqlConnection con = new SqlConnection("Data Source=192.168.0.16,49582;Network Library=DBMSSOCN;Initial Catalog=TrulyDB;uid=sa;pwd=sa@pass123;");

答案 1 :(得分:0)

There are different ways to Create Connection String which depends on 
Authentication type as you know 
1.> Windows Authentication 
2.> SQL Server Authentication

Follow this link