Tuesday, March 27, 2012

Exception Details: System.Data.SqlClient.SqlException: Login failed for user

this is an error i got while doing DB connection in C# .
i was wondering if my connectionstring is not correct.. but that was correct...
connection string is "connectionString="Data Source=<serverName>;Database=<DBName>;User ID=<Username>;pwd=<password>;""
what i found is, things should be as follows...
1st of all the user should have teh credentials of SQL Authentication.
and next the DB instance should be of mixed security mode...
if its only Windows Authentication, and you have created the above user in SQL Authentication, then it will throw the same error...
so to make the server in moxed mode login to the server with SQL Admin credential and right click on the server name and click properties...
then got to the "Security" link and select the "SQL Server and Windows Authentication Mode"
then restart the server and try..
this should work...

thanks,
yes.sudhanshu

No comments:

Post a Comment