mcs26
asked on
C# DataReader vs DataSet
Hi,
I am writing some code in C# that retrieves data from a microsoft access database. The question I have is when I should use a DataReader or DataSet? As I understand it DataReader is quicker and forward only where as a DataSet allows you more flexibility with your data.
When retriving the data I run one sql query once. It will typically return between 30,000 & 90,000 rows of data with between 4 to 10 fields (depends on the table called). Would this be to much in memory terms for a DataSet to work properly?
Thanks
I am writing some code in C# that retrieves data from a microsoft access database. The question I have is when I should use a DataReader or DataSet? As I understand it DataReader is quicker and forward only where as a DataSet allows you more flexibility with your data.
When retriving the data I run one sql query once. It will typically return between 30,000 & 90,000 rows of data with between 4 to 10 fields (depends on the table called). Would this be to much in memory terms for a DataSet to work properly?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the replies. But when it says,
"Use the DataReader in your application if you:
•Are processing a set of results too large to fit into memory."
How do you know or whats the rule of thumb when saying "to large to fit into memory"?
Cheers
"Use the DataReader in your application if you:
•Are processing a set of results too large to fit into memory."
How do you know or whats the rule of thumb when saying "to large to fit into memory"?
Cheers
see if you are expecting 1 million records it is not advisable to store those in DataSet for further processing as that will be stored in memory for a while, on the other hand we can use DataReader will read one row at a time and the process it. That will save memory as well as processing time.
Open in new window
I am not a fan of datasets as they are designed to somewhat act like mini in memory databases therefore, by nature making them less efficient. With that being said, be careful not to bloat your objects too much aswell because they can also very easily become inefficient.