1. Home
  2. Computing & Technology
  3. Visual Basic
Part 2 - Using ADO .NET - Access and OleDB
Access and ADO .NET make a powerful team!
Databases

The first article of this series introduced ADO .NET, Microsoft's new data access object library. This article will show you how to use ADO .NET with Access and VB .NET in several modes: read only and update mode using your own Access database. This week, Part I will explain a read only program and next week, an update program will be shown.


-----------------------------------------

About.com also has a database focused site at databases.about.com.

This series will focus on the VB .NET language aspects of ADO .NET. Go to About Databases for more information 'About' building and using databases.

-----------------------------------------


 More of this Feature
• 2 - The OleDbDataReader Object
• 3 - Coding A DataReader Application
• 4 - Try-Catch Error Processing
• 5 - Finishing the Application
• 6 - The Application Example Code
 
 Join the Discussion
Is this the kind of article that helps you?
Let us know!
 
 Related Resources
• VB .NET Books!
• New to VB .NET?
  Learn It Here!
 
 Elsewhere on the Web
• About.Com DATABASES
 

Starting at the beginning ...

For many people, the "beginning" is programming in Office using VBA, so here's the story on that. In the series 'About' VBA, I demonstrated how easy it was to 'instantiate' objects from other environments and use them in a VBA program with an Office application - such as Access! So the first question about ADO .NET might be, "Great! How do I use it in Access?"

Unfortunately, it can't be done according to Microsoft. ADO .NET was designed to work with .NET and not COM (the technology used by Office and VBA). Microsoft explains that even if you go through the steps to force Office to recognize ADO .NET, it still doesn't work:

"If you run RegAsm.exe (the Assembly Registration Tool in the .NET Frameworks SDK) to register System.Data.dll with COM (on which Office VBA is based), and then try to reference the generated type library file from Office, you will get no exposed members in the Office Visual Basic Object Browser. This is because COM fails to recognize core private ADO .NET members and parameterized constructors. So, for now at least, you should continue to use ADO in Office VBA."

Well ... it would have been nice. But stay tuned! Microsoft is just now (May 2003) releasing a new version of Office that allows it to call VB .NET programs. It's currently in beta test, but we'll provide more information when things firm up.

But even though you can't use ADO .NET in Access, you certainly can use it with an Access database.

Since there's a good chance that you will want to build your own database rather than using the Microsoft Northwind sample, a very simple Access database was constructed containing data about recent About Visual Basic Spotlight articles. Here's what that looks like:

Access database

Next page > The OleDbDataReader Object > Page 1, 2, 3, 4, 5, 6

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2008 About.com, a part of The New York Times Company.

All rights reserved.