How to Fill DataTable using SqlCeDataReader

  • Thread starter Thread starter Peter Foot [MVP]
  • Start date Start date
P

Peter Foot [MVP]

The Schema table will return details on the field returned, their datatypes
size etc which you would need to use to create a datatable to insert the
records into. You will need to do a considerable amount of work to duplicate
the functionality of the DataAdapter and at the end of the day you will
probably not improve on the performance of the DataAdapter. You should look
into the options you have available to reduce the amount of data you
retrieve at any one time - there is no getting away from the fact that the
more data you load into a dataset the longer it will take and the more
memory it will consume. Also if you are currently running the original RTM
release of the Compact Framework you should install Service Pack 1 as this
introduces some performance improvements in System.Data and other areas.

Peter
 
Hi,



How can I populate a DataTable using the
System.Data.SqlServerCe.SqlCeDataReader. The issue I'm having is how to get
the table structure from the SqlCeDataReader. I have looked at the
GetSchemaTable() method but can't figure out how to get the table
information from it. If someone could give a code snippet or point me to a
location that I can find information on how to populate a DataTable using a
SqlCeDataReader I'll be very grateful. I need to do this since
SqlCeDataAdapter Fill() method is too slow when loading large tables. Any
help or advice on this would be great.



Thanks in Advance!



Prasanna.
 
Hi Peter,



Thanks for the prompt reply. What I'm trying so hard to do is to create a
DataGrid that works fast. (Otherwise the uses will like the old eVC app. We
had a virtual list that only gets the records that are visible from the
CEDB). I'm currently struggling to implement the same thing in C# with
acceptable performance. I want to get only the data that will be displayed
on scream from the DB. I'm using System.Data.CommandType.TableDirect to
access the table (View like the SQLCE Query Analyzer grid). Any idea where I
can get some help on how to do this, or any ideas.



OLEDB had a feature where I could get the number of records of the table/SQL
which was executed. That is what we used to set the v-scroll max. I can't
find a why to get this information using the CF. Any help would be great
since I'm stuck for time.



Thanks again!



Prasanna.
 
Back
Top