Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have written a code in Visual Studio.NET and used data from SQL Server 2008. But after debugging, it says:

Login failed for user 'sunny'. 

When I try to set the user as something else, it keeps on saying that error. I start sql with windows authentication and the username there is: sunny-lptp\sunny.

I do not have any sql authentication user/pass on sqlserver express 2008.

I tried changing the authentication in server/security tab. I changed it to both windows and sql. but it didnt fix the error.

what should I do?

Here is the connection string in web.config:

<configuration> 
    <appSettings> 
        <add 
            key="SchoolsDBConnectionString" 
            value="server=sunny-lptp\sqlexpress;database=SchoolsDB;">
        </add> 
    </appSettings>

and code:

scn = new sqlConnection(
    ConfigurationManager.AppSettings["SchoolsDBConnectionString"].ToSt‌​ring());

any help ??

share|improve this question
3  
Have you set Integrated Security=true; in your connection string ? –  GX. Sep 20 '12 at 15:31
4  
Please show your Connection String. –  ron tornambe Sep 20 '12 at 15:33
    
I have this for connection : scn = new sqlConnection(ConfigurationManager.AppSettings["SchoolsDBConnectionString"].ToSt‌​ring()); and this for connectionstring in web.config: 'code' <configuration> <appSettings> <add key="SchoolsDBConnectionString" value="server=sunny-lptp\sqlexpress;database=SchoolsDB;"></add> </appSettings> –  SunnY Sep 20 '12 at 17:01
add comment

migrated from stackoverflow.com Sep 21 '12 at 15:55

This question came from our site for professional and enthusiast programmers.

2 Answers

Append on Trusted_Connection=True to the end of your connection string in your config file:

server=sunny-lptp\sqlexpress;database=SchoolsDB;Trusted_Connection=True

Great resource for connection strings

share|improve this answer
add comment

So I don't know integrated security or if that resolved your problem, however usually when I see a 'login failed' with a windows user, it has the whole username: "Domain\user". In your case it only states "Sunny" which might mean it's trying to use SQL Authentication.

Can you open up profiler and record 'failed logins' from your host and see what is going on? Let us know if it didn't work and we can dig deeper.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.