Advertisements

“Login failed for user” C# with SQLConnection


This is the Common Problem we are facing in Server DB Connection in Asp.net.If you are using windows authentication to connect to the Server DB, you need to set “Trusted_Connection=True;” if you are using SQL server authentication, you need to declare User “Id=myUsername; Password=myPassword;”

Code Snippet In Web.Config:

Windows authentication

<add name="windowsConnection" connectionString="Server=localhost; Database=databasename; Trusted_Connection=True;" />

SQL server authentication

<add name="Sqlserverconnection" connectionstring="server=localhost; Database=databasename;uid=db; password=123 "/> 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: