You are here:About>Computing & Technology>Delphi Programming
About.comDelphi Programming
New...Access Database from Delphi
Page 1: Delphi, ADOX and ADOExpress against MS Access.
 More of this Feature
• Page 2: Create.Database
 Join the Discussion
"Post your views and comments to this chapter of the free Delphi database Programming Course"
Discuss!
 Related Resources
• free DB Course.TOC
• Queries with ADO
• SQL with Delphi
• more Database articles

Chapter 11 of this course (Free Delphi Database Course for Beginners - focus on ADO techniques) featured the ADOCommand component which is most often used for executing data definition language (DDL) SQL commands. We've presented a way of porting your existing Paradox/BDE tables to MS Access. However few questions have stayed unanswered: how to create an empty Access database, how to add an index to an existing table, how to join two tables with referential integrity, ....

Many of the attendees of this course have complained that they do not have MS Access installed on their computer - and are unable to create a sample database (aboutdelphi.mdb) that is presented in the first chapter and used through this course.

In this chapter, we'll again focus on the TADOCommand and the ADOX to see how set up an empty MS Access database from "nothing".

   ADOX
As stated in the mentioned chapter, ADO Extensions for Data Definition Language and Security is an extension to the ADO objects and programming model. ADOX gives developers a rich set of tools for gaining access to the structure, security model, and procedures stored in a database.

Even though ADOX is part of ADO, Delphi does not wrap it inside ADOExpress. To use ADOX with Delphi, you should establish a reference to the ADOX type library. The description of the ADOX library is "Microsoft ADO Ext. for DDL and Security." The ADOX library file name is Msadox.dll. You'll have to import the ADOX library into the IDE.

To use ADOX in Delphi, you should establish a reference to the ADOX type library.
1. Select Project | Import Type Library
2. Choose "Microsoft ADO Ext 2.x for DDL and Security (Version 2.x)"
3a. Change "TTable" to "TADOXTable"
3b. Change "TColumn" to "TADOXColumn"
3c. Change "TIndex" to "TADOXIndex"
3d. Change "TKey" to "TADOXKey"
3e. Change "TGroup" to "TADOXGroup"
3f. Change "TUser" to "TADOXUser"
3g. Change "TCatalog" to "TADOXCatalog"
4. Press Install button (rebuilding packages)
5. Press OK once and Yes twice
6. File | Close All | Yes

This process creates a ADOX_TLB.pas unit and places its name in the uses clause of the current project. The process also places 7 new components on the ActiveX page of the component palette. It is very important to change the class names as described in step 3. If you omit that part Delphi will complain that class TTable is already defined - this is because the VCL already has the BDE version of TTable component.

aboutdelphi.mdb
Before we move on, you should recall that our sample aboutdelphi.mdb database has three tables: Application, Authors and Types. Both Authors and Types are child tables to Applications. Both Authors and Types have a primary index.

Next page > Create Database from Delphi > Page 1, 2

DB Course Next Chapter >>
>> Charting with Databases

From Zarko Gajic,
Your Guide to Delphi Programming.
FREE Newsletter. Sign Up Now!
Newsletters & RSSEmail to a friendSubmit to Digg
 All Topics | Email Article | | |
Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.