Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I read from a simple Access DB in code? 2

Status
Not open for further replies.

terryomag

Programmer
Aug 30, 2005
6
US
I have a fairly simple Access database, and I need to pull some of the fields from it, do some calculations and generate a report. I'd like to have a code example of how to recognize the database, how to open it for input, read selected valued from it, and then close it. I will NOT be updating the database, sinply reading some of the data and manipulating the data. I used to do this in VB 6.0, but everything seems to have changed. I don't wnat to write in VB 6.0 and convert the code to VB.Net. I'd really like to just access the data directly.
 
I'm not at all good with vb.net, but I think you want to use an OleDBDataReader. I bet if you posted this question in the vb.net forum you would be a better response. Or, better yet, look through the faq's and/or search in that forum.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
OleDBDataReader is right if you're using a firehose cursor (dbForwardOnly) in VB6. If you're only reading the data from top to bottom you can use it. If you need more functionality you'll want to look into the DataSet and its related objects, which give a good deal more functionality than the ADO objects did. (The DataSet object is like a mini DBMS in its own right, with all the associated classes that one might expect: a collection of DataTable objects which has a collection of DataRow objects, and a collection of DataRelation objects, and so on.) If you need to update (you said you didn't, but another time you will) use the DataAdapter object along with a DataSet.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top