Cannot open database "AdventureWorks" requested by the login. The login failed. received in web service
-
2008年11月11日 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.- 已编辑 fairyLiquid 2008年11月11日 18:01
- 已移动 Jenny Lo 2008年11月11日 19:04 (Moved from .NET Services and SQL Data Services - On-boarding Issues to Using the Microsoft SQL Server Protocols)
全部回复
-
2008年11月12日 15:44版主
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- 已建议为答案 Hongwei Sun-MSFTMicrosoft Employee, Moderator 2008年11月12日 15:44
- 已标记为答案 Alex MorrillMicrosoft Employee, Owner 2008年11月17日 22:56

