Solved

VB.Net: data structures

Posted on 2009-07-08
6
1,009 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 27

Accepted Solution

by:
VBRocks earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now