Java
vcon.Open();
SqlCommand cmd = new SqlCommand("select question from examQuestion where tchId='123'", vcon);
SqlDataReader dr = cmd.ExecuteReader();
String[] getQuestion = { "" };
int i = 0;
while (dr.Read())
{
getQuestion[i] = dr.GetString(0);
i++;
}
vcon.Close();
It is fine when database contain single value, But when database has more then one value it provide an Error "Index was outside the bounds of the array". What is the problem? Please Help me. I am very new at
ASP.Net.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 20, 2013, 8:48 PM EDT
Since you are using string array, there fore it need to change the size dynamically which is bit complicted. Use ArrayList which is simple
Regards,
Iftikar