only My site

Saturday, December 13, 2008

DataTable Load()


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: