我只想知道遠程sql server express版本的正確sql連接字符串。適用於C#的遠程SQL服務器的正確連接字符串
這是我得到了,但我得到了一些問題
SqlConnection cs = new SqlConnection(@"Data Source=(IP Address)\PC-NAME\SQLEXPRESS,1433;Network Library=DBMSSOCN;Initial Catalog=dbase;User ID=sa;Password=password");
我在C#中的調試器得到這個錯誤:事先
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
謝謝!
請記住,如果我問192.168.0.100 IP地址發生了什麼?我在連接字符串中看不到。謝謝 – Danny
@Danny實際的服務器地址需要在調制解調器/路由器的端口轉發中設置。連接字符串告訴SQL客戶端連接到調制解調器,該調制解調器然後將連接轉發到內部服務器。從客戶的角度來看,服務器位於公共地址,而不是私人地址。 – Corey
@Corey如果我連接到安裝了SQL Server的Azure中的虛擬機,並且允許遠程訪問,該怎麼辦?在這種情況下,我可以把IP地址如果虛擬機在數據源? –