Accessing Data Using ADO

Since its introduction in 1993, Microsoft Access has been effectively used by people all over the world for organizing and accessing data. While each new software release brought numerous changes in the design of the user interface and offered simpler ways of performing common database tasks, database access has evolved at a little slower pace.

Since Version 1.0, an integrated part of Microsoft Access has been its database engine, commonly referred to as Microsoft Jet or Jet database engine. Jet databases are stored in the familiar .mdb file format. The only way you could access a native Microsoft Access database (Microsoft Jet) programmatically in the early 1990s was by using the data access technology known as Open Database Connectivity (ODBC). This technology made it possible to connect to relational databases using appropriate ODBC drivers supplied by database vendors and third parties. While this technology is still in use today, it is not object-oriented and is considered by many to be quite difficult to work with. To access data via ODBC you need a specific ODBC driver installed on the computer containing the data source.

With the release of Access 2.0, Microsoft enabled programmers to efficiently access and manipulate Microsoft Jet databases with a technology called Data Access Objects (DAO). DAO consists of a hierarchy of objects that provide methods and properties for designing and manipulating databases. Although you will still encounter numerous Microsoft Access VBA programs that use the DAO Object Model, it is recommended that you perform your database programming tasks by using another object model known as ActiveX Data Objects (ADO).

Access 2000 was the first version to support ADO. Microsoft Office Access 2003 continues to use ADO as its main and preferred method of data access. ADO works with the new technology known as OLE DB. This technology is object-based, but it is not limited to relational databases. OLE DB can access both relational and non-relational data sources such as directory services, mail stores, multimedia, and text files, as well as mainframe data (VSAM and MVS).

To access external data with OLE DB you do not need any specific drivers installed on your computer because OLE DB does not use drivers; it uses data providers to communicate with data stores. Data providers are programs that enable access to data. OLE DB has many providers, such as Microsoft OLE DB Provider for SQL Server or Microsoft Jet 4.0 OLE DB Provider. There are

Part II

also providers for Oracle, NT 5 Active Directory, and even a provider for ODBC.

Accessing and manipulating data programmatically with ADO requires that you establish a connection to the desired data source. The Microsoft Jet database engine enables you to access data that resides in Microsoft Jet databases, external data sources (such as Microsoft Excel, Paradox, or dBASE), and ODBC data sources. This chapter demonstrates various ways of opening both native Microsoft Jet databases as well as external data sources. You will also learn how to establish a connection to the currently open database, connect to an SQL server, create a new database, set database properties, and handle database errors.

0 0

Post a comment