Sunday 15 January 2012

asp.net - C# - Convert SqlDataReader to ArrayList -


Is there a way to convert SqlDataReader into an array list?

I have to pass the result of a query from one page to another so that I can tie it in the gridview. However, I can not pass SqlDataReader object in session.

How do I get the following?

  if (rdr.HasRows == true) {while (Rdr.Read ()) {arraylist.add (full line); // pseudo code}}   

thanks :)

Using a SqlDataReader to create DataTable and pass this object

  DataTable dt = New DataTable (); If (rdr.HasRows == true) dt.Load (rdr);   

A very complete example can be found with different options available - you can now pass the entire datatyon instance and use it to bind the gridwind

No comments:

Post a Comment