0
我有一個控制檯應用程序,並希望連接其他Windows服務器,我已經創建了用戶,數據庫表。在conf.xml中我有連接其他服務器數據庫
<configuration>
<crypto location="172.16.10.34" database="Crypto_Pan" username="PinbySms" password="ASDasd123"/>
</configuration>
然後我的代碼是:
Dictionary<string, string> d = conf.getCrypto();
SqlConnectionStringBuilder bu = new SqlConnectionStringBuilder();
bu.DataSource = d["location"];
bu.NetworkLibrary = "DBMSSOCN";
bu.InitialCatalog = d["database"];
bu.IntegratedSecurity = false;
bu.UserID = d["username"];
bu.Password = d["password"];
SqlConnection thisConnection = null;
try
{
thisConnection = new SqlConnection(bu.ConnectionString);
thisConnection.Open();
Console.WriteLine("success connected");
}
catch (Exception e)
{
Console.WriteLine("exeption: " + e.ToString());
thisConnection.Close();
}
我有一個錯誤,當我的應用程序嘗試連接該數據庫:
[System.Data.SqlClient的.SqlException] = {「與SQL Server建立連接到 SQL Server時出現與網絡有關的或 實例特定的錯誤。未找到服務器或無法訪問。驗證 實例名稱是正確的,並且SQL Server配置爲允許遠程連接的 。
有沒有人有任何建議?
地址不正確或SQL Server未配置爲允許遠程連接 - 該IP是否可訪問?你可以連接其他任何東西嗎? –
來自連接字符串構建器的連接字符串是否具有預期的內容?其他工具可以使用相同的細節連接到該數據庫嗎? (將連接字符串放在配置文件中有什麼問題:這裏有一整段內容?) – Richard
我確定希望這些不是您真正的憑據... –