am trying to read the data using SqlDataReader.
But during execution of this code reader shows "Enumeration yielded no results".
string connetionString = null;
SqlConnection cnn;
SqlCommand cmd;
string sql = null;
SqlDataReader reader;
connetionString = "Data Source=INBAGHPC00840;Initial Catalog=Testing;Persist Security Info=True;User ID=sa;Password=12345";
sql = "select * from [Category]";
cnn = new SqlConnection(connetionString);
try
{
cnn.Open();
cmd = new SqlCommand(sql, cnn);
reader = cmd.ExecuteReader();
while (reader.Read()) //Here reader shows : Enumeration yielded no results
{
// MessageBox.Show(reader.GetValue(0) + " - " + reader.GetValue(1) + " - " + reader.GetValue(2));
}
reader.Close();
cmd.Dispose();
cnn.Close();
}
catch (Exception ex)
{
//MessageBox.Show("Can not open connection ! ");
}
I couldn't quite get what I am missing here. Please let me know..