Book Review: Beginning Visual Basic 6 Databases
The latest technology that performs this magic is OLE DB. OLE DB is designed to provide universal access to several relational and non-relational data sources. We will communicate with OLE DB using Active Data Objects. By using ADO in conjunction with OLE DB, we can talk to Access, Oracle, SQL Server, or any other data source by simply using the ADO object model.
To the VB6.0 database programmer, ADO is the interface we need to understand. Take a look at this figure:
Notice that this object model is much 'flatter' than the previous diagram. ADO and UDA are all about simplicity.
You can see that by using ADO from either a web browser or a Visual Basic 6.0 application, we can talk to just about any data source. OLE DB handles the grunt work out of our sight to make all of this magic work. And best of all, ADO is actually easier to work with than DAO! As we mentioned, Microsoft has indicated that DAO and RDO will eventually be replaced with ADO. So it does make sense to start learning it now. OLE DB will now handle working with the standard relational data and non-relational data from just about anywhere on the planet.
Let's take a closer look at ADO. We'll begin by making sure that VB knows all about ADO.
Try It Out - Telling VB About ADO
1 Start a new project called Chapter11prjfirstADO. Now go into the Project | References dialog and add the Microsoft ActiveX Data Objects 2.0 Library and ActiveX Data Objects Recordset 2.0 Library references to your project.
Now VB 6.0 knows about the ADO components we want to use.
Then right click on your tool palette and select Components. Select the Microsoft ADO Data Control 6.0 (OLEDB):
Click OK. This will add an ADO data control to your palette.
2 Name the default form in the project frmADO. Draw an ADO Data Control (ADODC) on the form. Next, draw a textbox and label as shown on the form as well. We are going to create a simple bound text box program like our first data control program. And we will use the label to show where we are in the recordset.
In order to hook up the ADODC to our Biblio.mdb database, we must first set some properties. We did this a bit earlier in the book, remember?
Right click on the ADODC and select ADODC Properties. This will bring up a Property Page dialog box for the control. The first thing we must do is tell the control some important information. Unlike the singular DatabaseName property we need to set on the standard data control, the ADO data control requires a connection string. The connection string consists of the specific OLE DB provider to use, as well as the data source we want to access. The connection string is the critical piece of information the ADODC control needs to find the data source. Let's take just a minute to review the connection string, because we will be using them for the rest of the examples in this chapter, and though the rest of the book.
Page 6 of 23