I have searched for a good couple hours now, looking for a solution to this problem. I am trying to get information from my database using the code below with the correct qu
Not sure if this is the problem in your case, but you should always check the result of Read(). eg
if (myReader.Read())
{
statement = myReader.GetString(0);
}
Edit: Also what you are actually doing is retrieving a scalar, and as such you could use ExecuteScalar()
return (myCommand.ExecuteScalar() ?? string.Empty).ToString();
//also rename your method appropriately