我試圖用我的C#代碼連接到SQL Server,但無法建立連接,它一直拋出用戶abcdef的異常登錄失敗。錯誤:用戶SQL Server的登錄失敗
當我使用相同的憑證通過SQL Server Management Studio連接到數據庫時,它工作正常,沒有任何問題。
<connectionStrings>
<add name="Conn"
connectionString="Server=xxxx\yyyy;User ID=abcdef;Password=******;Initial Catalog=mytestDB;"/>
</connectionStrings>
string strDBCon = ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = strDBCon;
sqlConnection.Open();
是否該用戶有權限「mytestDB」分貝呢? –
是的,我可以通過SSMS連接並從該數據庫進行查詢 –
您是否從本地計算機運行ssms? –