Solved

How to backup and restore a database table.

Posted on 1998-01-30
3
178 Views
Last Modified: 2010-04-04
I am kind of stuck (AGAIN)


I am currently using a paradox table and would like to if possible
backup and restore a table on disk.

I have thought of using the BatchMove by setting it mode property to baCopy but I was not sure if it allowed you to backup the table to disk.

P.S. A small bit a code if possible would be appreciated....




0
Comment
Question by:delbrad
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
d4jaj1 earned 50 total points
ID: 1358052
Batchmove will do.  If the table doesn't exist, it will create it for you.  Although batchmove (baCopy) works, I prefer to do a regular DOS copy to move all of the files from one directory to another (your Backup directory).  I prefer this method because the batchmove doesn't copy the referential integrity, indexes, validity checks, etc., just the table's structure.  Using the DOS method allows you to keep your tables and other of their associated files in tact.

In terms of code, I would suggest a REALLY good Freeware component that automatically gets all fields specified in a MASK, e.g., Customers.*, and moves/copies them to a directory.  It's called FileOps and can be found at Torry's Delphi website.  If you can't find it there, add I comment and I'll send it to you.

If your set on using the batchmove, first create the table like your existing table and perform the move.  You will have to add val checks & ref-integrity yourself.

try
 with table1 do //your existing table
 begin
 fielddefs.update;
 indexdefs.update;
 end;
 tempdb := ttable.create(nil);  // create a new table from scratch to look just like your existing table
 with tempdb do begin
 DataBaseName := table1.databasename;
 tableName := 'backup.db';
 TableType := table1.tabletype;
 fielddefs.assign(table1.fielddefs);
 indexdefs.assign(table1.indexdefs);
 createtable;
 open;
 end;
 table1.batchmove(temdb, batcopy)
 tempdb.free;
except
 raise;
 end;

Any questions, please add a comment.  Good Luck!

Jay
0
 

Author Comment

by:delbrad
ID: 1358053
To  d4jaj1

Went to Torry's Delphi Page and could not find the freeware component called FileOps

Could you send it to me at

delbrad@brigadoon.com

thank you

P.S. will also try provide code to see which one I like the best...
0
 
LVL 3

Expert Comment

by:d4jaj1
ID: 1358054
Will send it to you.  The code for the Batchmove is above, the FileOperations component has an example program (source code included) in the zip file.  It is compatible with D2 & D3.

Good Luck.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 169
Thread safe  opinion 7 126
Strange code, can use it, but i cant figure out what it does. 3 54
Using idhttp to login to instagram 2 76
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now