Class to use VB6-style access of VB.Net data objects

  • Thread starter Thread starter Rob Richardson
  • Start date Start date
R

Rob Richardson

Greetings!

It seems to me that .Net is much more typing-intensive than VB6 was.
Instead of getting a recordset and reading a value from it using something
like "Name = MyRecordset("name")", I have to say something like "Name =
MyDataset.Tables(0).Rows(0)("Name")". I am tempted to write a class that
would inherit from DataSet and would provide the same interface that the VB6
RecordSet object did. It would have to have MoveFirst, MoveNext, EOF, and
BOF methods and such like.

Before I try to build something like this, I'm curious: Has anyone else
already done this?

Thanks very much!

Rob
 
The DataReader functions in more or less that manner.
Every time you call Read( ) on the DataReader, it advances one row, like
MoveNext in the old ADO classes, and you can get a value from the current
row just by specifying the name or position as in your example. However,
note that the DataReader is forward-only read-only.

-Rob Teixeira [MVP]
 
Rob,
Before I try to build something like this, I'm curious: Has anyone else
already done this?
Yep! Microsoft did!

Look up "Typed DataSets" in the online help:

Some links from a quick MSDN search that look promising.

http://msdn.microsoft.com/library/d...us/vbcon/html/vbtskcreatingadonetdatasets.asp

http://msdn.microsoft.com/library/d...conadonetdatasetcreationinvisualstudionet.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnhcvb03/html/vb03f9.asp

http://msdn.microsoft.com/library/d.../html/cpcongeneratingstronglytypeddataset.asp

In case you don't have it, you may want to pick up David Sceppa's book
"Microsoft ADO.NET - Core Reference" from MS Press. It is a good tutorial on
ADO.NET, plus a good desk reference once you know ADO.NET. Also David's book
gives some insight on how the Typed Datasets work...

Hope this helps
Jay
 
Back
Top