ASP.NET - Login failed for user ''. The user is not associated with a trusted SQL Server connection.

Asked By pankaj kumar on 05-Feb-10 02:41 PM

hi,

i want to load my sql database on hoster server. and i m using connectionstring like this

connectionString="Data Source=propertyencyclopedia.com;Initial Catalog=Main;Integrated Security=SSPI"

here propertyencylopedia.com is name of my website. and main is my database. but when i want to view the page then error generating. error.....

Login failed for user ''. The user is not associated with a trusted SQL Server connection.

plz any body solve my problem. thanx in advance. plz


You are using Windows Authentication. So, you need to give the Network Service windows account

Robbe Morris replied to pankaj kumar on 05-Feb-10 03:44 PM

permission to access your database.  Or, adjust your SQL Server instance to accept SQL authentication and pass a username/pwd in the connection string.

ASP.NET sites in IIS typically run under the windows account Network Service or IUSER_machinename account.  When IIS handles a page request, it is running under one of these accounts by default.  That same authentication is getting passed onto SQL Server and you don't have SQL Server configured to permit this user access to your database.

pankaj kumar replied to Robbe Morris on 05-Feb-10 04:02 PM
i m using connectionstring

connectionString="Data Source=propertyencyclopedia.com;Initial Catalog=Main;Integrated Security=SSPI"

what will i give in data source. and from where i can get user name and passwprd.

pankaj kumar replied to pankaj kumar on 05-Feb-10 04:08 PM
plz any body solve my problem. plzzzzzzzzz.
pankaj kumar replied to pankaj kumar on 05-Feb-10 04:09 PM
my authentication mode is form
If you continue to use Windows Authentication in SQL Server - Robbe Morris replied to pankaj kumar on 05-Feb-10 04:28 PM

The connection string doesn't change.  You log onto the SQL Server and add the windows accounts I mentioned to the database.  If you have logged onto SQL Server and enabled SQL Authentication, the the connection string would look like this:

"Data Source=propertyencyclopedia.com;Initial Catalog=Main;User Id=YourNewUser;Password:YourNewUserPassword"

Remember to give the account you create (YourNewUser) in SQL Server access to your database.

mv ark replied to pankaj kumar on 05-Feb-10 08:54 PM
Inspect the detailed error message. From the State (represented by one of the numbers below), you can make out the precise reason why the login has failed & take further action.

State - Description
2 -  User ID is not valid.
5 -  User ID is not valid.
6 -  An attempt was made to use a Windows login name with SQL Server Authentication.
7 -  Login is disabled, and the password is incorrect.
8 -  The password is incorrect.
9 -  Password is not valid.
11 -  Login is valid, but server access failed.
12 -  Login is valid login, but server access failed.
18 -  Password must be changed.

For more info on this topic, check the MSDN article on this topic - http://msdn.microsoft.com/en-us/library/ms366351.aspx
Suman replied to pankaj kumar on 04-Feb-11 04:10 PM
http://www.sumanpradhan.com/post/2011/02/04/Configuration-Error-2.aspx
Kapil replied to pankaj kumar on 02-Jun-11 11:23 AM
Nothing to get panic just add one more filed to your Connection String

Trusted_Connection=no

It will work... :)