【发布时间】:2014-10-07 22:19:46
【问题描述】:
我发现,我的 SQL 服务器禁用了命名管道,但启用了 TCP/IP(它将保持这种状态)。现在我正在尝试从视觉工作室连接到数据库,但没有运气。 到目前为止我已经尝试过:
string connstring = "Data Source=192.168.1.1:1433 ;Initial Catalog=np-sparcsn4-custom;Persist Security Info=True;User ID=xxxx;Password=/*****/";
string connstring = "Data Source=192.168.1.1:1433 ; Network Library=DBMSSOCN; Initial Catalog=np-sparcsn4-custom;Persist Security Info=True;User ID=xxxx;Password=/*****/";
我尝试用名称替换 IP 地址 - 不走运。当我尝试使用表适配器进行连接时,我可以预览数据,如果我使用即网格也是如此 - 但在代码中我根本无法打开与它的连接:我总是有网络相关或服务器特定错误,通常是它要么
Named Pipes Provider: Could not open a connection to SQL Server [5]
或
provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server
服务器已设置为接受远程连接并且可以访问。
更新:
我试过了
string connstring = "Server=tcp:192.168.1.1,1433 ;Initial Catalog=np-sparcsn4-custom;Persist Security Info=True;User ID=xxx;Password=/****/";
或
"Server=tcp:ponln4report,1433 ....
我有错误:
provider: TCP Provider, error: 0 - A non-recoverable error occurred during a database lookup**strong text**
EDI2:我找到了一个较旧的 SQL Server 2005,我可以毫无问题地连接。这有点痛苦,因为它缺少日期和时间数据类型,但我想现在必须这样做。
【问题讨论】:
-
您是否确保 SQL Server 已启用 TCP/IP 并可访问?
-
是的,它们已启用
-
查看 SQL Native Client 10.0 配置节点下的内容:是否启用了 tcp/ip?
-
很抱歉,如果它实际上不是重复的,请关闭您的问题。没想到我的投票会像个banhammer :)
-
再次启用,问题已更新
标签: c# sql-server sql-server-2008 ado.net connection-string