This is my aspx code when i want to fetch just one record.
conn = new SqlConnection(cs);
string sql = "SELECT * FROM [school_database].[arrest_school].[registration_allstudent] where RegistrationId='llts4da2'";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
reader = cmd.ExecuteReader();
reader.Read();
Model.Registration regis = new Model.Registration();
regis.Address = reader["Address"].ToString();
return regis;
Now i want to fetch all the records and return regis array. How to do it.
I know how to count the row in read and then how to fill it regis array.
Regis has 5 fields…Address, city, name, class, phoneno
To read all the records, one way is this:
Another way is this: