IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi for W...Using DataBDE   Print This     
  From the July 2015 Issue of Prestwood eMag
 
A 10 Minute Delphi 2009 Paradox BDE TTable Quick Start
 
Posted 21 years ago on 3/18/2003 and updated 2/8/2010
Take Away:

This KB Post addresses accessing Paradox tables through the BDE using TDatasource, TTable, and TDBGrid. This tutorial was updated for Delphi 2009 but applies to all versions of Delphi.

KB100147

Got 10 minutes? Want to get started with Delphi 2009 Paradox BDE TTable?

This article is part of our series of 10 Minute Quick Starts. Each quick start is step by step, assumes you know very little about the subject, and takes about 10 minutes. You can use them to scratch the service of areas you want to learn and as a quick review when returning to something after a long absence.

Introduction

This KB Post addresses accessing Paradox tables through the BDE. This is probably the simplest and most common data access method. I'll assume no previous experience with Delphi. In future talks, we'll discuss accessing SQL servers such as Interbase, MS-SQL, and Oracle, using ADO, bypassing the BDE, performing common data access needs, and much more.

The following tutorials will utilize the tables in the DBDEMOS folder. By default these tables are installed to C:\Program Files\Common Files\Borland Shared\Data. To access these tables we'll use the installed alias DBDEMOS. (An alias is the shortcut way that Delphi and the Borland Database Engine refers to a folder.)

Tutorial Overview

In this first tutorial we'll display the data from the Customer.db table and allow users to edit the data.

  1. Create a new application

    Select File | New | VCL Forms Application (File | New Application in older Delphi versions). Delphi creates and displays a unit1.pas file and displays Form1. Actually, Delphi just created a whole new application for you that included the main project1.dpr file and a unit1.dfm form file. The .DPR project file is the main file that starts all your code. In addition, the .EXE executable file that is created when you compile will have the same name as the project file but with a .EXE extension.
     

     

  2. Place a TTable Component on the form

    If the source code for Unit1 is showing, switch to the default form created by selecting F12 (this toggles between the form and unit files). From the BDE tab (Data Access tab in earlier versions) of the component palette, select the component called TTable and place it anywhere on the form. The TTable component gives you access to a specific table. It's a very powerful component with lots of properties and methods and, for BDE developers, it is important to study.
     

     

  3. Set the alias for the TTable
     
    With the TTable selected, select the drop down for the DatabaseName property and select DBDEMOS. This tells the TTable component where to look for a table.
     
    Note: If you don't see DBDEMOS then you need to reinstall Delphi. Alternatively, you can use any Paradox table you have including the Cutomer.db table included in the Sample alias with Paradox.
     

  4. Point the TTable component to a particular table

    With the TTable selected, select the drop down for the TableName property and select customer.db. This tells the TTable component what table to use.

  5. Activate the TTable component

    With the TTable selected, set the Active property to True. This tells the TTable component to open the table. Now we have an open table but nothing displayed. The next few steps will show you a common technique for displaying data.

  6. Place a TDataSource, TDBGrid, and TDBNavigator components on the form

    From the Data Access tab of the component palette, select the component called TDataSource and place it anywhere on the form. TDataSource provides an interface between a dataset component (for example a TTable) and data-aware controls such as fields and grids on a form.
     
    From the Data Controls tab, place a TDBGrid and TBDNavigort components on your form. Your form should now look similiar to:
      

  7. Select Datasource1 and set DataSource1.DataSet := Table1.

  8. Select DBGrid1 and set DBGrid.DataSource := DataSource1
  9. Select the DBNavigator and set DBNavigator.DataSource := DataSource1
  10. Save and run
     

Time to Explore!

Now that you have gotten your feet wet with BDE-based Delphi development, repeat these steps with the Orders table but set MasterSource and MasterFields properties.


Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1116A1
Enter key:
KB Post Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #100147 Counter
20519
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]