Does not iterate through datarow
Hi, i get this error where it does not iterate through datarow row and control passes to the end of the program.? The sql fetches only one row, i have this code on page load as well and it works fine there as there are multiple records. thanks..
cmd6 = new SqlCommand("select * from daysavailable where Doc_Id=@Id", sqlconnect);
// cmd6.CommandType = CommandType.StoredProcedure;
cmd6.Parameters.Add(new SqlParameter("@Id", textBox1.Text));
datareadr6 = cmd6.ExecuteReader();
if (datareadr6.Read())
{
dt3.Clear();
dt3.Load(datareadr6);
MessageBox.Show(dt3.Rows.Count.ToString());
if(dt3.Rows.Count > 0)
{
foreach (DataRow row in dt3.Rows)
{
for (int j = 0; j < checkedListBox1.Items.Count; j++)
{
string str2 = row.ItemArray[j + 1].ToString();
if (str2 == "y")
{
checkedListBox1.SetItemCheckState(j, CheckState.Checked);
}
else
{
checkedListBox1.SetItemCheckState(j, CheckState.Unchecked);
}
}
}
}
}