I want to get the total data of my table and store into one variable
This is my code...but it gives me error like 'Invalid attempt to read when no data is present.'
try
{
GetConnection();
MySqlCommand.CommandText = "Select COUNT(source) from [dbo].[Company_info] where source = '"+source+"'";
MySqlDataReader = MySqlCommand.ExecuteReader();
if(MySqlDataReader.HasRows==true)
{
string sourcecount = MySqlDataReader[0].ToString();
MessageBox.Show("Data Inserted..!! : "+sourcecount);
}
}
catch
{
}