Solved

VB.Net: data structures

Posted on 2009-07-08
6
1,021 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:Inglorious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24802261
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.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24802306
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.
0
 

Author Comment

by:Inglorious
ID: 24803076
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?
0
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 
LVL 27

Accepted Solution

by:
VBRocks earned 50 total points
ID: 24804243
Inglorious - Yes, absolutely.  You can create your own custom classes with validate, etc., and create a new instance for each row in the DataTable.

There is a huge advantage to using DataTables, though, and that is that they automatically support binding, sorting and filter.  You don't have to do any programming for that to work!  It's very nice.

On the other hand, if you decide to create your own custom classes, then you have to create a list class, and implement the binding, sorting  and filter yourself, which is a lot of work.  And if you don't really understand that, then you might just want to go with ADO.NET.

Check out this book review I did at Amazon, it discusses this issue:

http://www.amazon.com/gp/cdp/member-reviews/AZIRONOELH2Y3/ref=cm_cr_pr_auth_rev?ie=UTF8&sort_by=MostRecentReview

0
 

Author Comment

by:Inglorious
ID: 24815247
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 :)
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 24815331
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/

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question