CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2008
    Posts
    12

    Q's about datasets/datareaders

    I'm moving from VB.Net into C# and am developing data access classes. In VB.Net I always used a dataset since it gave me full ability to manupilate the data; read/write/update/delete. I've been reading on the net where some people disagree to using datasets, espcially in ASP.Net.

    Ok but my question is, how can a data reader take the place of a dataset? How do you update a row with a datareader? If you can't, what does one do? Use SQL Insert statements to add records? Delete/Add instead of Read/Update?

    For ASP.Net and VB.Net, I'd create data classes with all the needed data management code in a DLL for shared use by the desktop and web application. In this case, ASP.Net isn't using a dataset, it's calling a DLL that uses a dataset.

    Are they that horrible and what's the alternative? (specifically for updates)

    Thanks!

  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Q's about datasets/datareaders

    Quote Originally Posted by meshman
    I'm moving from VB.Net into C# and am developing data access classes. In VB.Net I always used a dataset since it gave me full ability to manupilate the data; read/write/update/delete. I've been reading on the net where some people disagree to using datasets, espcially in ASP.Net.
    I dont do asp.net so I cant comment 100% on your situation, however..

    Ok but my question is, how can a data reader take the place of a dataset?
    That's kinda like asking if a tap can take the place of a bucket

    How do you update a row with a datareader?
    You dont

    If you can't, what does one do? Use SQL Insert statements to add records?
    Yes, just like the DataSet generator designs for you. If you never looked into the mechanics of a tableadapter and a datatable then you might rightly be confused. A DT is a bucket, it stores rows of info that change, are new, are to be deleted etc
    When you invoke tableadapter.Update() it scans all rows, and fires off either an INSERT UPDATE or DELETE query depending on what the user did to the row (is it Added, Modified or Deleted RowState).

    Further you should note that TA uses a DataAdapter which wraps a DataReader. There is no rocket science here and there is no concept of "DataSet vs DataReader" - two different things for different purposes. a DataReader is the only way data comes out of a database.. its just how many layers of friendly abstraction its wrapped in


    For ASP.Net and VB.Net, I'd create data classes with all the needed data management code in a DLL for shared use by the desktop and web application. In this case, ASP.Net isn't using a dataset, it's calling a DLL that uses a dataset.
    I dont see a problem

    Are they that horrible and what's the alternative? (specifically for updates)
    No, and there is no alternative. INSERT UPDATE AND DELETE are the only way to change data in the DB, SELECT via datareader is the only way of getting it out. As noted before, it's abstraction and codegen
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  3. #3
    Join Date
    Jul 2008
    Posts
    12

    Thumbs up Re: Q's about datasets/datareaders

    "Further you should note that TA uses a DataAdapter which wraps a DataReader."

    That's what I needed. Awesome reply, thanks so much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured