1个回答
展开全部
//下面代码针对sqlserver的 Q是AdoQuery 组件
//备份
var sql:String;
begin
if (filename.Text='') then
begin
Application.MessageBox('请选择文件','提示',MB_ICONWARNING);
exit;
end;
sql:='BACKUP DATABASE "mao" TO DISK ='''+filename.Text+''' with init';
Q.SQL.Text:=sql;
q.ExecSQL;
Application.MessageBox('数据库备份成功','提示',MB_ICONWARNING);
end;
//还原
var sql:String;
begin
if (fname.Text='') then
begin
Application.MessageBox('请选择文件','提示',MB_ICONWARNING);
exit;
end;
Q.SQL.Text:='use master';
Q.ExecSQL;
sql:='RESTORE DATABASE "mao" FROM DISK='''+fname.Text+'''';
Q.SQL.Text:=sql;
q.ExecSQL;
Q.SQL.Text:='Use mao';
Q.ExecSQL;
Application.MessageBox('数据库还原成功','提示',MB_ICONWARNING);
//备份
var sql:String;
begin
if (filename.Text='') then
begin
Application.MessageBox('请选择文件','提示',MB_ICONWARNING);
exit;
end;
sql:='BACKUP DATABASE "mao" TO DISK ='''+filename.Text+''' with init';
Q.SQL.Text:=sql;
q.ExecSQL;
Application.MessageBox('数据库备份成功','提示',MB_ICONWARNING);
end;
//还原
var sql:String;
begin
if (fname.Text='') then
begin
Application.MessageBox('请选择文件','提示',MB_ICONWARNING);
exit;
end;
Q.SQL.Text:='use master';
Q.ExecSQL;
sql:='RESTORE DATABASE "mao" FROM DISK='''+fname.Text+'''';
Q.SQL.Text:=sql;
q.ExecSQL;
Q.SQL.Text:='Use mao';
Q.ExecSQL;
Application.MessageBox('数据库还原成功','提示',MB_ICONWARNING);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询