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.
SQL Select query of more than one value of a same Attribute
I have a Sql Database with many attributes. From there i want to take
all the value of question attribute in an array named getQuestion Here
Is my code
Iftikar HussainPosted Jul 21, 2013, 12:48 AM
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