System.IndexOutOfRangeException: index was outside the bounds of the array c#... the code is attached below.
List<dbcategory> complainList1 = new List<dbcategory>();
string q = "select * from comp_detail where Roll_no ='" + RollNo + "'";
var cmd = new SqlCommand(q, con);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
dbcategory db = new dbcategory();
db.id = sdr[0].ToString();
db.subject = sdr[1].ToString();
db.Description = sdr[2].ToString();
db.invName = sdr[3].ToString();
db.category = sdr[4].ToString();
db.picture = sdr[5].ToString();
db.teacherRemarks = sdr[6].ToString();
db.status = sdr[7].ToString();
String date = sdr[8].ToString().Split(' ').ElementAt(0);
db.RollNo = sdr[9].ToString();
db.date = date;
complainList1.Add(db);
}
con.Close();
return complainList1;