Backup restore local SQL Server database

zhaozj2021-02-11  203

Backup Restore SQL Database // Data Backup can only back up the local database server

String filename = "";

IF (SD-> Execute ())

{

Filename = SD-> filename;

}

Else

{

Return;

}

Screen-> Cursor = CRHOURGLASS;

TadoQuery * QRBK = New TadoQuery (this);

QRBK-> Connection = DM-> adocon;

QRBK-> SQL-> text = string ("Backup Database Erp to Disk = ') FileName String ("' ");

Try

{

QrBk-> EXECSQL ();

}

Catch (...)

{

DELETE QRBK;

QrBk = NULL;

Screen-> Cursor = crdefault;

ShowMessage ("Backup Failed! / N Please select Different File Name! / N Original file name:") filename);

Return;

}

DELETE QRBK;

QrBk = NULL;

Screen-> Cursor = crdefault;

ShowMessage (String ("Backup success! / N file name:") filename);

//Data Recovery

String filename = "";

IF (od-> execute ())

{

Filename = od-> filename;

}

Else

{

Return;

}

Screen-> Cursor = CRHOURGLASS;

TadoQuery * QRBK = New TadoQuery (this);

QRBK-> Connection = DM-> adocon;

QrBK-> SQL-> Text = String ("Use tempdb / n restore database erp from disk = ') filename string ("' / n use erp / n ");

Try

{

QrBk-> EXECSQL ();

}

Catch (...)

{

DELETE QRBK;

QrBk = NULL;

Screen-> Cursor = crdefault;

ShowMessage ("Restore Failed! / N Please confirm that there is no other program to access the database! / N and restore the file intact! Restore file name:") filename);

Return;

}

DELETE QRBK;

QrBk = NULL;

Screen-> Cursor = crdefault;

ShowMessage ("Restore success! / N file name:") filename);

转载请注明原文地址:https://www.9cbs.com/read-5816.html

New Post(0)