meshman
July 15th, 2008, 07:29 PM
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!
cjard
July 18th, 2008, 05:35 AM
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
meshman
July 24th, 2008, 10:53 AM
"Further you should note that TA uses a DataAdapter which wraps a DataReader."
That's what I needed. Awesome reply, thanks so much.