Backup: VARFILENAME: STRING; strsql: string;
beginif openDialog1.Execute then begin FileName: = openDialog1.FileName; showmessage (FileName); try strsql: = 'backup database carxt to disk =' '' FileName '' ''; rs.Close; rs.SQL.Clear; rs . SQL.Add (strsql); rs.execsql; if FileExists (fileEname) Then ShowMessage ('has been backed up by:' filename); Except Messagedlg ('data backup exception!', MTerror, [Mbok], 0) ; End;
Restore: if OpenDialog1.execute thenbegintryconn.connected: = false; // Turn off CARXT database conn2.open; rs.Connection: = conn2; rs.close; rs.sql.clear; rs.sql.add ('alter Database Carxt01 set Offline with rollback immediate '); rs.Execsql; rs.close; rs.sql.clear; rs.sql.add (' restore database carxt01 from disk = '' ' OpenDialog1.FileName ' ''); rs.execsql ShowMessage ('successfully completed the database restore!'); finallyrs.close; rs.sql.clear; rs.sql.add ('alter Database carxt01 set online with rollback immediate'); // Reconnect database carxt01rs.execsql; conn2 .Connected: = false; // Turn off the connection of the master Conn.Connected: = true; rs.connection: = conn; end; end;