-1

Possible Duplicate:
Connecting to Database mdf without SQL Server

I have a simple web service that working and queries a simple .mdf database.

I'm using IIS and making it an working application.

I can activate every function on this web service from anywhere.

I'm running SQL Server 2005 Express.

I gave all the permissions needed to run this.

But when I try to query the database I get this error:

*Cannot open database "gateway" requested by the login. The login failed.
11-28 15:22:58.464: W/System.err(762): Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

This is my connection string:

<add name="gatewayConnectionString" 
     connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=gateway;Integrated Security=True" 
     providerName="System.Data.SqlClient"/>
Community
  • 1
  • 1
Gladi
  • 415
  • 4
  • 16
  • 1
    Daniel, the problem is that you don't know SQL Server. Where did this database come from? You should get help from whoever created it. – John Saunders Nov 28 '12 at 13:52
  • ive created this database in my visual studio 2010 project. project with a single webservice and database file(mdf). i can run this ws methods perfectly fine... just the methods that queries the db returning this exception... – Gladi Nov 28 '12 at 14:22

1 Answers1

0

When you are using Integrated Security=True in your connection string, you should give permissions to NT AUTHORITY\NETWORK SERVICE user for your "gateway" database. Below is the what you can do.

Connect your SQL Server Management Studio, below your server name, go to SECURITY, then go to LOGINS, you must see a login/user with name NT AUTHORITY\NETWORK SERVICE. If you cannot see, then right click on LOGINS, cilck NEW LOGIN. A popup window will appear. Hit SEARCH button in front of "Login Name" field. From here, search for NT AUTHORITY\NETWORK SERVICE user from your computer and select it. Then go to USER MAPPING tab, select your database name "gateway", check the checkbox. Then select the db_owner role from checkbox list below. Select OK. And now test it again.

I hope this answers your question, if yes then mark it as "answered".

gofr1
  • 15,741
  • 11
  • 42
  • 52
raheel khokhar
  • 366
  • 2
  • 5
  • hi, thanks for your answer. i did that and its still the same... same error appears... – Gladi Nov 28 '12 at 14:12
  • Did you add the "NT AUTHORITY\NETWORK SERVICE" for domain or your computer user to your database? Domain account won't work, local machine account will only work. Also try adding "public" permissions along with "db_owner" .permissions. – raheel khokhar Nov 28 '12 at 17:50