DataTable's Load method.
===================
string sql = "Select * from MyTable";
SqlCommand cmd = new SqlCommand(sql, MyConnection);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
//Load the SqlDataReader object to the DataTable object as follows.
dt.Load(dr);
Response.Write(dt.Rows.Count.ToString());
No comments:
Post a Comment