無法連接到localhost (provider:命名管道提供程序,error: 40 - 無法打開到 SQL Server 的連接)
1. 確保服務器端的數據庫中存在sa,並支持混合登錄模式.默認安裝的時候,可能會忽略建立sa.
2. 確保服務器端的數據庫是支持遠程調用的.打開SQL server Management Studio,選擇該數據庫,右鍵菜單"Properties",在打開的對話框
中選擇Connections,把Allow remote connections to this server選上.
3. 確保服務器端的SQL服務的TCP/IP是Enable的.打開SQL server Configuration Manager. 選擇SQL server 2005 Network
Configuration下的Protocols for SQL2005( 我安裝的SQL示例名爲SQL2005), 把Named Pipes和TCP/IP都修改爲Enabled,默認是Disabled.
4. 確保服務器端的SQL實例的遠程調用是支持TIP/IP和named pipes的. 打開SQL server Surface Area Configuration Manager,在打開的
頁面中選擇Surface Area Configuration for Services and Connections.選中實例的Remote Connections,把Using both tcp/IP and named
pipes選中.
5. 重啓服務器端的SQL server 2005服務,確保SQL server Agent和SQL server Browser的服務也啓動了. 默認都是需要手動啓動,可以改
成Automatic.
6. 因爲服務器端的操作系統是WinXp+SP2,所以還需要檢查防火牆.確保防火牆中的1433端口打開了.
[實際解決方法:]
打開SQL server Surface Area Configuration Manager,在SQL Server 2005服務中啓動SQL Server
打開SQL server Surface Area Configuration Manager,在SQL Server 2005網絡配置中啓動Named Pipes和TCP/IP