Reputation: 1360
I'm having problems whenever I run my application, it says that the connection is wrong. The error is User '' has failed.
I think I didn't specify the user id and password but I don't know what is the user id and my password.
Here's my connection string
public SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=PayrollDB;Persist Security Info=True;");
Thanks in advance!
Upvotes: 1
Views: 24617
Reputation: 1201
To allow windows authentication, you need to add integrated security set as tru in your connection string like this:
public SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=PayrollDB;Persist Security Info=True;Integrated Security=true;");
Upvotes: 1
Reputation: 8545
public SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=PayrollDB;Persist Security Info=True;Integrated Security=true;");
add Intergrated Security=true to connection string.
Upvotes: 6
Reputation: 21
You need to add the connection string attribute: Integrated Security = true
. And this will work correctly.
Upvotes: 2