|
Technical answers from the trenches |
|
Copying Paradox (and dBASE) Tables
| ||||
Posted: 9 May 2002 |
||||
  |
Applies to: Recent versions |
|||
  |
Audience: Intermediate |
|||
Question: How can I backup a Paradox table using Delphi? (By backup, I mean "make a copy of the data, indexes, and valchecks?")Answer: There are several ways you can approach the problem, however, many suffer from one or more weaknesses:
In our experience, the most effective way to backup a Paradox (or dBASE) table is to call a function provided by the Borland Database Engine (BDE) for that purpose, as shown in the following code sample: // Add DB, DBTables, DBIProcs to USES
procedure copyTable( const strSource, strTarget : String );
var
hDB : HDBIDB; // Handle to the database
const
OVERWRITE_FLAG = Bool( TRUE );
begin
screen.cursor := crHourglass;
with TTable.Create( Application ) do
try
// verify source table exists and grab handle
DatabaseName := extractFilePath( strSource );
TableName := extractFileName( strSource );
open;
hDB := DBHandle;
close;
// make the backup
check( dbiCopyTable( hDB, OVERWRITE_FLAG,
pChar( strSource ), 'PARADOX',
pChar( strTarget ) ) );
finally
free;
screen.cursor := crDefault;
end;
end;To use this procedure, call it using something along these lines: copyTable( 'C:\data\pxsample\customer.db',
'c:\temp\answer.db' );
Please note that you need to include the name of the table--and extension--in the target parameter. Also, you should note that the above example makes certain assumptions; it assumes:
If one or more of these assumptions aren't appropriate for your application, adjust CopyTable() accordingly. For more information about dbiCopyTable() and other functions provided by the BDE API, please refer to the BDE32.HLP Help file. By default, this is installed to C:\Program Files\Common Files\Borland Shared\BDE. |
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|