Link to home
Start Free TrialLog in
Avatar of Inglorious
Inglorious

asked on

VB.Net: data structures

Hi,

I just started programming in VB.Net and I'm doing some research on available data structures.

I'm going to read data from the sqlDB and at some point load it into the appropriate objects.

I have been programming in java for a while, so my first instinct is to get the data into the result set, then iterate through the result set and map the data into my objects.

I'm aware of the DataSets and dataAdapters, however, I'm not entirely sure what one I should be using.

I'm not interested in the code, just some general advise on data structures in VB.Net and how you would go about mapping the data from MS SQL Server onto VB.net objects.

Thank you
Avatar of kaufmed
kaufmed
Flag of United States of America image

You say "I'm not entirely sure what one I should be using." DataAdapters and DataSets actually work together. A DataSet will be like your ResultSet--it holds the data you retrieved from the DB (in DataTables!). A DataAdapter manages retrieval and updating of data held in a DataSet. For example, the DataAdapter holds the SQL to retrieve and update the DB to/from the DataSet within it SelectCommand and UpdateCommand properties, respectively. All you have to do is something like dataAdapterName.Fill(dataSetName) to load data from DB to DataSet.
There is a specific command to commit changes made to the DataSet to the DB, but I don't recall the name off the top of my head. An update example was lacking in my last post.

Also, I mentioned DataTables. DataSets consist of one or more DataTables hold the actual data. This allows you to have multiple queries/tables from the DB within a single Dataset. The column names of the DataTables will be those of the table selected or the columns/aliases of the select query.
Avatar of Inglorious
Inglorious

ASKER

Hey,

Thank you for your response.

I looked at the way DataSets work. Thank you very much for pointing me in that direction.

Is it a good idea, or is it actually possible to map records from the dataTables onto someObject, so that each record in a dataTable is an instance of some class.

Is it a good approach to get data from the dataSet, manualy load it into some object, load object into the array list and then work with that array list by invoking methods on the objects?
ASKER CERTIFIED SOLUTION
Avatar of VBRocks
VBRocks
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for the response.

I actually know how to do it "long/hard" way, but I never came across data sets/tables, dataReaders and .Net  API in general.

Just finished the prototype - dataTables are indeed very flexible, porwerful and simple to use.

Thank you again :)
You're welcome!

If you're ever interested, there's a book that was written by David Sceppa, it's called "Programming ADO.NET 2.0 Core Reference", and it's an awesome book!  They may have 3.5/4.0 by now, because it's been a while since I bought that, but I keep it around as a reference.

    http://www.davidsceppa.net/