Skip to content Skip to sidebar Skip to footer

Database Login Failed For User

I am aware that this question repeats from time to time but I tried almost every response here and I still encounter a problem with code below that tries to connect to my MS SQL Se

Solution 1:

There are few types of authentications in SQL Server like windows, server etc.

The login you created via SQL will try to login via SQL Server authentication mode. So make sure your SQL Server allows use that type of the authentication.

You can check you SQL server settings:

Right click on server name -> Properties -> Security:

Mixed mode authentication should allow both windows and server:

enter image description here

Solution 2:

I would like to thank you for your answers. Solution is in code below:

SqlConnectionStringBuilderbuilder=newSqlConnectionStringBuilder();
builder.DataSource = ".";            // DataSource changed             
builder.InitialCatalog = "DATABASE";
builder.IntegratedSecurity = true;
SqlConnectionconnection=newSqlConnection(builder.ConnectionString);
connection.Open();

Post a Comment for "Database Login Failed For User"