Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. I receive this error when I try to connect to the database 'CSE-DEPT' through my vc# applicaton. My connection string is:

C#
SqlConnection conn = new SqlConnection(@"server = .\sqlexpress; integrated security = true ;database = CSE_DEPT");

I tried the solution of
"Go to SQL Server >> Security >> Logins and right click on NT AUTHORITY\NETWORK SERVICE and select Properties. In newly opened screen of Login Properties, go to the "User Mapping" tab. Then, on the "User Mapping" tab, select the desired database – especially the database for which this error message is displayed. On the lower screen, check the role db_owner. Click OK."


but it didnt work.
Your detailed answer is appreciated for this beginner
Posted
Updated 11-Jul-12 7:43am
v2
Comments
[no name] 11-Jul-12 14:20pm    
Are you logging into your windows desktop as yourself or NETWORK SERVICE?
cs101000 12-Jul-12 1:36am    
I have an administrator windows user account that I have logged into and also want to login to sql server with that
[no name] 12-Jul-12 7:36am    
And did you set up your user account with access to the database? Why are you messing around with the network service account?
cs101000 12-Jul-12 9:16am    
I think I did. Because I can access the database with that account (and windows authentication) by sql server management studio. The connection problem occurs when I wana connect through vc# app. And as I said in the comment of solution 1 I checked db_owner in that account, too.
[no name] 12-Jul-12 9:53am    
Compare the connection string from management studio with the connection string that you are using and see if they are the same.

Quote:
"Go to SQL Server >> Security >> Logins and right click on NT AUTHORITY\NETWORK SERVICE and select Properties. In newly opened screen of Login Properties, go to the “User Mapping” tab. Then, on the “User Mapping” tab, select the desired database – especially the database for which this error message is displayed. On the lower screen, check the role db_owner. Click OK.



Instead of doing this with the Network Service, repeat the service with your own account name.
 
Share this answer
 
Comments
cs101000 12-Jul-12 2:03am    
done! I still get the error
http://i.imgur.com/cMQe1.png

Bases on this, login failed for user "REZA-CS\REZA"

Credentials provided for the user were incorrect. Give complete connection string with username and password. Try out and see.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900