Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...How to Convert IDataReader to DataSetHow to Convert IDataReader to DataSet
Previous
 
Next
New Post
10/4/2006 10:21 PM
 

In order to use the DataGrid's built-in paging, the DataSource must implement ICollection (so that the DataGrid can determine the total count of records in the DataSource and hence the number of pages that will be needed.  An IDataReader implements the IEnumerable rather than ICollection interfaces as one cannot determine the total number of records without enumerating through the data.

As has been mentioned, there is no simple type conversion from IDataReader to a DataSet. The process would involve enumerating though the records and adding them one by one to the rows of a DataTable.

Rather than using SqlHelper.ExecuteReader in your SqlDataProvider code to return an IDataReader, I would suggest that you look into using the Public Shared Sub SqlHelper.FillDataSet which populates one or more DataTables of a supplied DataSet.

Another soultion would be to use the SqlHelper.ExecuteReader in your SqlDataProvider code to return an IDataReader, but then in your module's controller code use the CBO.FillCollection method to return either an ArrayList or better yet in ASP.NET 2.0 a generic list of strongly typed objects.  For example from a module I'm now working on:

Public Function GetEPrayers(ByVal ModuleId As Integer) As List(Of EPrayerInfo)
   
Return CBO.FillCollection(Of EPrayerInfo)(DataProvider.Instance().GetEPrayers(ModuleId))
End Function

Either the ArrayList or the GenericList can then be passed into the DataGrid's DataSource without complaint.

Finally, if you must pass an IDataReader into the DataGrid you could enable custom paging (AllowCustomPaging=True), obtain the count of records by some other means, and pass it to the DataGrid's VirtualItemCount property. You'll also have to provide your own paging of the data.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
10/4/2006 11:15 PM
 

There is actually a core method in Common.Globals:

        Public Function ConvertDataReaderToDataSet(ByVal reader As IDataReader) As DataSet

Which will do the job for you.


My comments are my own and are offered WITHOUT PREJUDICE

Shaun Walker
http://www.siliqon.com
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...How to Convert IDataReader to DataSetHow to Convert IDataReader to DataSet


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out