Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

SQL server access failed at runtime...

I have made a small ASP.NET application accessing Northwind database in SQL Server on a DIFFERENT computer than the one where IIS is. During development of this application, i gave the valid username and password in process of defining SQLConnection datacontrol, i even tested the connection which was perfect. When i run my application, it says invalid "login failed for user username". what should i do? for sure, username and password are perfectly right for the database. :confused:
[486 byte] By [premartha] at [2007-11-11 7:18:25]
# 1 Re: SQL server access failed at runtime...
If you use windows login this is how the connection string should be
"server=localhost;database=Northwind;Integrated Security = SSPI"
If you use SQL Server login
"server=localhost;database=Northwind;uid=sa;password=sa"
Since your sql server is on a different machine , where both the machines are on the same domain, and you are using windows authentication, your windows user account should be added to the sql servers users with adequate permissions, Also while defining the SQLConnection if you specified a user name try specifying domain\username in case of windows
srinivas_s at 2007-11-11 23:13:50 >
# 2 Re: SQL server access failed at runtime...
What level of authentication is your ASP.NET application using? Are you attempting to use a trusted connection with SQL Server?
pclement at 2007-11-11 23:14:55 >
# 3 Re: SQL server access failed at runtime...
What level of authentication is your ASP.NET application using? Are you attempting to use a trusted connection with SQL Server?

i am sorry, i am very new to this technology. I dnt even know what r different levels of authentication and what is a trusted connection. can u help me giving me any reference to resources regarding this?
premartha at 2007-11-11 23:15:53 >
# 4 Re: SQL server access failed at runtime...
You can set up your web application (using Internet Services Manager) for different levels of authentication, such as Anonymous, Basic, Integrated NT, etc). I'm trying to figure out which level your ASP.NET is configured for.

Also, since you're specifying a user ID and password in your connection string it doesn't appear as if you're using a trusted connection (which essentially involves automatically using the identity of the Windows authenticated user).
pclement at 2007-11-11 23:16:54 >
# 5 Re: SQL server access failed at runtime...
it worked now. the problem was in connectionstring property, password was not there. infact, i mentioned user name and password both during setting up my dataadapter. but afterwards, in properties box, i saw it was missing!!

can u suggest me some resources to study on different levels of authentication in detail?
premartha at 2007-11-11 23:17:53 >
# 6 Re: SQL server access failed at runtime...
The following should help:

IIS 5.0:
http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/Default.asp?url=/technet/prodtechnol/windows2000serv/reskit/iisbook/c09_iis_5.0_authentication_modes.asp

IIS 6.0:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/9b619620-4f88-488b-8243-e6bc7caf61ad.mspx
pclement at 2007-11-11 23:18:57 >