none
DataSet vs. DataReader RRS feed

  • Question

  • Hi !
    I am trying to build a sistem wich lets me define the text wich will go on several buttons I have, here in my application . In order to do this , I have a "Configuration" section where I choose the "Category", the button wich will have his text changed and a Datagridview wich will hold the list of Products according to the choosen category. I just need to display data to the user . I have been searching and I found that Datareaders are superior to DataSets . Since I  have to display the same data several times (when the user clicks on other category, a new list of products will be shown) I don't know if its best to keep up with a simple Datareader wich gets Data from DB when asked to do so or a DataSet, where I would store all the records from the DB relative to the products and then, in the code , iterate over all the rows and display the ones I am looking for . Performance is a priority for me Smile

    Sorry if this isn't the appropriate place to post these type of questions ...

    Best Regards,
    Ivan Frias.
    Friday, May 2, 2008 7:12 PM

Answers

  • Saying that DataReaders are superior to DataSets is a lot like saying that FileStreams are superior to strings:  it's true for very narrowly-defined values of "superior," but generally not.

     

    Unless you have very large numbers of rows, or the data in the database is changing frequently, you should be caching the data in your application instead of going to the database whenever you need to display a value.  The DataSet is generally the right tool for that job.

    Friday, May 2, 2008 7:53 PM

All replies

  • Saying that DataReaders are superior to DataSets is a lot like saying that FileStreams are superior to strings:  it's true for very narrowly-defined values of "superior," but generally not.

     

    Unless you have very large numbers of rows, or the data in the database is changing frequently, you should be caching the data in your application instead of going to the database whenever you need to display a value.  The DataSet is generally the right tool for that job.

    Friday, May 2, 2008 7:53 PM
  •  

    It is an interesting discussion even if it isn't a question. But they do different things really. The functionality of a reader is sort of one of many things that the data adapter itself must use to work with datasets. And the reader (as you say) lets you implement your logic at a lower level, so the performance will be better if the logic is simpler. The only requirement might be "read this data". Then a reader is suitable. An interesting topic!
    Friday, May 2, 2008 8:01 PM