Solved

How to backup and restore a database table.

Posted on 1998-01-30
3
177 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

11 Experts available now in Live!

Get 1:1 Help Now