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()
string ret = "";
//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 XmlReader
rdr = command.ExecuteXmlReader();
while (rdr.ReadState != ReadState.EndOfFile)
ret += rdr.ReadOuterXml();
//Add a root element
"<vendors> " + ret + "</vendors>";
catch (Exception ex)
throw new Exception(ex.Message);
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.