I have the following code:
public string GetClients()
{
string outputxml = string.Empty;
Database db = DatabaseFactory.CreateDatabase("MyDatabase");
SqlCommand sqlcmd = db.GetSqlStringCommand("SELECT CLIENTID, CLIENTNAME FROM [CLIENTS] FOR XML AUTO, ELEMENTS") as SqlCommand;
using (XmlReader reader = sqlcmd.ExecuteXmlReader()) //Exception thrown in this line
{
while (reader.Read())
{
outputxml = reader.ReadOuterXml();
}
return outputxml;
}
}
This method is part of an exercise I'm doing as a part of WCF self-tutoring.
While invoking this method from a WCF client application, I get the error mentioned in the subject of this post at the spot marked above. The connection string to the database is specified in the config file for MyDatabase, and it is set as the Default database as well.
What am I doing incorrectly here? Thank you SOF community.