我發現,我的SQL服務器已禁用命名管道,但啓用了TCP/IP(它會保持這種方式)。現在我試圖從Visual Studio連接到數據庫,但沒有運氣。 到目前爲止,我已經試過:通過TCP/IP連接到SQL服務器,而不是NP
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地址 - 沒有運氣。當我嘗試使用表格適配器進行連接時,我可以預覽數據,如果使用ie網格,也是如此 - 但是在代碼中,我根本無法打開連接:我總是遇到與網絡相關的或服務器特定的錯誤,通常是無論是
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嗎? – abatishchev 2014-10-07 22:36:27
是的,它們已啓用 – Yasskier 2014-10-07 22:40:28
檢查SQL Native Client 10.0配置節點下的內容:是否啓用了tcp/ip? – Isantipov 2014-10-07 22:40:47