i know its been asked alot and i have looked alot into this but all the solution that are given i have used but nothing seems to work for my case ,, so i thought to post my solution that is not working here .. i have comboboxes on form and i am selecting the difficulty level for questions to display from datatable ,, it seems to be working fine then suddenly message box pops up showing there is no row position at 0 , then sometimes 7 15 etc .. the datatable is filled then why my array is not positioning at rows. plz help
private void Diff_SelectedIndexChanged_1(object sender, EventArgs e)
{
using (var conn = new SqlConnection(constring))
{
SqlCommand cmd = new SqlCommand(cmdText, conn);
try
{
conn.Open();
SqlDataAdapter sd = new SqlDataAdapter(cmdText, conn);
sd.Fill(quest_);
if (quest_.Rows.Count > 0)
{
PopulateQuestion(0);
catch (Exception exp)
{
MessageBox.Show(exp.ToString());
}
finally
{
//con.Close();
}
}
exception "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll
Additional information: There is no row at position 16."it runs fine for sometime but then this exception