Bharathi Raja

Bharathi Raja

  • NA
  • 1.1k
  • 54.1k

invalid attempt to access a field before calling read() c#

Dec 1 2017 12:23 AM
connection.Close();
connection.Open();
cmd = new MySqlCommand("select attend from credit_purchase where date='" + date + "'", connection);
dread = cmd.ExecuteReader();
while (dread.Read())
{
x = dread.GetValue(0).ToString();//this line to error
}
dread.close(); 
connection.close(); 

Answers (2)