簡體   English   中英

SQL Server Express的連接字符串錯誤

[英]Error with connection string for SQL Server Express

我開發了一個軟件來提醒我的客戶將來他想做什么。

我可以在自己的筆記本電腦中使用它,但是當我創建安裝文件並將其安裝在客戶筆記本電腦中時,它會出現一些錯誤。 當我在自己的筆記本電腦上使用此軟件時,我的連接字符串為

server=localhost;database=Reminderdatabase;Trusted_Connection=true;

當我想在客戶筆記本電腦中使用它時,我使用此連接字符串

@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ReminderDatabase.mdf;Integrated Security=True;user instance=true;

我在他的筆記本電腦和.net Framework 4.0上安裝了SQL Server 2008 R2。

現在,當我要連接到數據庫時,發生了一個錯誤,說

建立與SQL Server的連接時發生與網絡相關或特定於實例的錯誤。 服務器未找到或無法訪問。 驗證實例名稱正確,並且將SQL Server配置為允許遠程連接。(提供者:SQL網絡接口,錯誤26-錯誤指定服務器/實例的位置)。

這讓我感到困惑。 我在50多個鏈接中尋找它,但它給我的答案不是很好。 我沒有更多的時間來學習和搜索用戶實例或類似的東西並理解它。 請告訴我該如何解決此錯誤。

非常感謝您的幫助

試試這個

 @"Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ReminderDatabase.mdf;Integrated Security=True;user instance=true;

服務器端:

Make sure that you have enabled remote connections on the instance (RELYONDB) of SQL Server.
Make sure that firewall is OFF.
Make sure that firewall has been configured to make an exception for SQLBROWSER.EXE and SQLSERVR.EXE in server computer.

客戶端:

Make sure that you have typed correct server computer name and instance name
Make sure that server machine is reachable. Check you are able to ping the server.
Make sure that you are able to access the shared folder of remote server.
Make sure that you are able to connect SQL Server using the Telnet command.

解決方法1:

啟用同時使用TCP / IP和命名管道:

所有程序| Microsoft SQL Server 2005 | 配置工具| SQL Server外圍應用配置器| 服務和連接的配置| 在“遠程連接”中,選擇“本地和遠程連接|啟用同時使用TCP / IP和命名管道”。

重新啟動SQL Server RELYONDB和SQL Server瀏覽器服務。

解決方法2:

啟用同時使用TCP / IP和命名管道:

所有程序| Microsoft SQL Server 2005 | 配置工具| SQL Server配置管理器| SQL Server網絡配置| 右鍵單擊“命名管道”並單擊啟用>右鍵單擊“ TCP \\ IP”並單擊啟用

重新啟動SQL Server RELYONDB和SQL Server瀏覽器服務。

解決方法3:

單擊開始| 運行 鍵入firewall.cpl | 關閉| 單擊確定。

要么

在Windows防火牆中創建例外。

將TCP端口或sqlservr.exe添加到防火牆例外列表中,或者添加“ .. \\ Binn \\ sqlsevr.exe”或添加端口。

將Sql Browser服務添加到防火牆例外列表中,您可以添加程序“ C:\\ Program Files \\ Microsoft SQL Server \\ 90 \\ Shared \\ sqlbrowser.exe”或添加UDP端口1434

解決方法4:[客戶端]

檢查客戶端和服務器系統中是否都在執行Ping操作

單擊開始| 運行 輸入cmd | 點擊確定

以“以管理員身份運行”打開命令提示符| PING類型

解決方法5:[客戶端]

解決DNS緩存:

單擊開始| 運行 輸入cmd | 點擊確定

以“以管理員身份運行”打開命令提示符| 輸入ipconfig / flushdns

解決方法6:[客戶端]

在連接字符串而不是主機名中提供服務器IP地址。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM