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
I have just walked away from a similar issue as yours.My solution was to use a
if (!myReader.HasRows)
{
}
just before walking through the dataset.
while(myRead.Read()
{
//read tuples
}
This would mean for your code:
public static string ExecuteSelect(string query)
{
//Example query is: SELECT entity_id FROM catalog_product_flat_1 WHERE
sku='itemSku';
string statement = "";
MySqlCommand myCommand = new MySqlCommand(query, _conn);
MySqlDataReader myReader;
myReader = myCommand.ExecuteReader();
myReader.Read();
if(!myReader.HasRows)
{
//set your statement variable to some generic value
statement="abracadabra";
}
while(myReader.Read())
{
statement = myReader[0].ToString();
}
myReader.Close();
return statement;
}