Login failed. The login is from an untrusted domain and cannot be used with Windows authentication
Problem:
Let’s have a web.config file whose connection string defined as below
<add key="Main.ConnectionString" value="Data Source=SQLEXPRESS;Initial Catalog=MyDB; Persist Security Info=True;User ID=sa;Password=****;integrated security=true;" />
While we are trying to run this program we will get error as “System.Data.SqlClient.SqlException: Login failed.
The login is from an untrusted domain and cannot be used with Windows authentication.”
Solution:
Now we will look into that how could we resolve this error.
We just need to change integrated security=true; to integrated security=false;
So finally our modified connection string will look as below:
<add key="Main.ConnectionString" value="Data Source=SQLEXPRESS;Initial Catalog=MyDB; Persist Security Info=True;User ID=sa;Password=****;integrated security=false;" />
Thanks leave your comment.