I am trying to access my local database using a web service also running locally on the Default Website in IIS7. I previously always used Windows Authentication but I read that to use web services you have to use SQL Server authentication, I have no experience with this but tried it out. I created a new login, but when I try using those credentials in my connection string:
connectionString="Server=.\SQLExpress;Database='SponsorChild';Trusted_Connection=True;User Id=abc;Password=abcpass" name="SponsorChildDatabase"/>
and try using the web service, I get the error:
System.Data.SqlClient.SqlException: Cannot open database "SponsorChild" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
So it seems not even the right user is being passed. Moreover, when I try logging in using SQL Management Studio, it also gives me a login error (error 18456 with state 38). I apologize if this is just some rookie mistake, but I’m just starting out with databases and website building and still have a lot to learn. Any help is greatly appreciated.
Trusted_Connection=Trueuses the Windows credentials and not the provided username and password. The user you’ve setup in the database doesn’t play a role. You either need to use SQL Server auth or authenticate the Windows account the service is running under.This is a sample connectionstirng not using Windows credentials: