Cannot open database "AdventureWorks" requested by the login. The login failed. received in web service
-
Dienstag, 11. November 2008 17:53
I have downloaded SQL Server 2005 Express addition and I am trying to connect to the Adventure Works database via a web service written in c# using VS2005. I can connect to the database through VS2005 and I know it is using my windows account.
The confusion I am having is how you find out what ASPNET account is being used to access the webservice.
I Thought it was the same as the windows account, but on reading it uses the ANONYMOUS users...I believe, but how do you check this?
Also how do you set the ASPNET account to have read write permissions on the ADVENTUREWORKS database?
The database and webservice reside on the same machine.
I have used the following code to try and connect to the database
public string GetVendorList(){
SqlConnection sqlConn; XmlReader rdr; string ret = ""; try{
//Open connection to SQL Express string connString = @"server=.\sqlexpress;Integrated Security=SSPI;initial catalog=AdventureWorks";sqlConn =
new SqlConnection(connString);sqlConn.Open();
//Return XML data the FOR XML AUTO clause string sqlString = "SELECT VendorId, AccountNumber, Name, CreditRating " + "FROM Purchasing.Vendor " + "WHERE ActiveFlag = 1 " + "ORDER BY Name " + "FOR XML AUTO "; SqlCommand command = new SqlCommand(sqlString, sqlConn); //Execute SQL query and return XML to XmlReaderrdr = command.ExecuteXmlReader();
rdr.Read();
while (rdr.ReadState != ReadState.EndOfFile){
ret += rdr.ReadOuterXml();
}
//Add a root elementret =
"<vendors> " + ret + "</vendors>";sqlConn.Close();
rdr.Close();
}
catch (Exception ex){
throw new Exception(ex.Message);}
return ret;}
I keep getting the following error on the sqlConn.Open();
"Cannot open database "AdventureWorks" requested by the login. The login failed."
I have tried to set the sa user in SQL Server Management Studio Express to public but do not really know what I am doing. I have searched the web for 4 days now and cannot find any info for a step by step check in SQL Server Management Studio Express.
Any help would be great as I am a beginner to C# and to SQL Server Express.
Thanks.- Bearbeitet fairyLiquid Dienstag, 11. November 2008 18:01
- Verschoben Jenny Lo Dienstag, 11. November 2008 19:04 (Moved from .NET Services and SQL Data Services - On-boarding Issues to Using the Microsoft SQL Server Protocols)
Alle Antworten
-
Mittwoch, 12. November 2008 15:44Moderator
This forum is for discussion of the open protocol documentation. Please re-post your question at the following forum and they should be able to assist you:
http://forums.microsoft.com/TechNet/ShowForum.aspx?ForumID=87&SiteID=17
Hongwei Sun -MSFT- Als Antwort vorgeschlagen Hongwei Sun-MSFTMicrosoft Employee, Moderator Mittwoch, 12. November 2008 15:44
- Als Antwort markiert Alex MorrillMicrosoft Employee, Owner Montag, 17. November 2008 22:56

