C#コードを使用してSQL Serverに接続しようとしていますが、接続を確立できず、ユーザーabcdefの例外ログインに失敗しました。エラー:ユーザーSQL Serverのログインに失敗しました
SQL Server Management Studioを使用して同じ資格情報を使用してDBに接続すると、問題なく正常に動作します。
<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();
接続文字列を呼び出すには、ユーザーが同様にDB "mytestDB" へのアクセス権を持っていることをしていますか? –
はい、SSMS経由でそのDBから接続してクエリできます –
ローカルマシンからssmsを実行していますか? –