如何恢复sql数据库(100分)

  • 主题发起人 主题发起人 xieshaofeng
  • 开始时间 开始时间
X

xieshaofeng

Unregistered / Unconfirmed
GUEST, unregistred user!
如何用delphi恢复sql用户数据库,最好提供一段源码,谢了。
 
procedure TForm1.Button1Click(Sender: TObject);
begin
{try
adoc.Prepared:=true;
adoc.CommandText:='sp_addumpdevice ''disk'',''accountbackup'',''c:/mssql7/backup/account.bak'''; //±¸·ÝÊý¾Ý¿â
adoc.Execute;

adoc.Prepared:=true;
adoc.CommandText:='backup database account to accountbackup'; //±¸·ÝÊý¾Ý¿â
adoc.Execute;
messagebox(self.Handle,pchar('Êý¾Ý¿â±¸·Ý³É¹¦!'),'Êý¾Ý¿â±¸·Ý',MB_OK+MB_ICONINFORMATION);
finally
adoc.Prepared:=true;
adoc.CommandText:='sp_dropdevice ''accountbackup''';
adoc.Execute;
end;}
//try
//adoc.Prepared:=true;
//adoc.CommandText:='sp_addumpdevice ''disk'',''bigconsumer'',''c:/mssql7/backup/bigconsumer1.bak''';
//adoc.Execute;

adoc.Prepared:=true;
adoc.CommandText:='backup database bigconsumer to disk=''c:/mssql7/backup/bigconsumer1.bak''';
adoc.Execute;
showmessage('Íê³É');
//finally
//adoc.Prepared:=true;
//adoc.CommandText:='sp_dropdevice ''bigconsumer''';
//adoc.Execute;
//end;
end;
 
adoquery1.close;
adoquery1.sql.clear;
adoquery1.aql.add('restore database 自定义数据库 from disk='用户数据库所在的路径'');
adoquery1.execsql;
恢复数据库时是独占式,连接到master 数据库 .我不知道是不是你所需要的。
 
procedure TForm1.Button1Click(Sender: TObject);
begin
{try
adoc.Prepared:=true;
adoc.CommandText:='sp_addumpdevice ''disk'',''accountbackup'',''c:/mssql7/backup/account.bak'''; //±¸·ÝÊý¾Ý¿â
adoc.Execute;

adoc.Prepared:=true;
adoc.CommandText:='backup database account to accountbackup'; //±¸·ÝÊý¾Ý¿â
adoc.Execute;
messagebox(self.Handle,pchar('Êý¾Ý¿â±¸·Ý³É¹¦!'),'Êý¾Ý¿â±¸·Ý',MB_OK+MB_ICONINFORMATION);
finally
adoc.Prepared:=true;
adoc.CommandText:='sp_dropdevice ''accountbackup''';
adoc.Execute;
end;}
//try
//adoc.Prepared:=true;
//adoc.CommandText:='sp_addumpdevice ''disk'',''bigconsumer'',''c:/mssql7/backup/bigconsumer1.bak''';
//adoc.Execute;

adoc.Prepared:=true;
adoc.CommandText:='backup database bigconsumer to disk=''c:/mssql7/backup/bigconsumer1.bak''';
adoc.Execute;
showmessage('Íê³É');
//finally
//adoc.Prepared:=true;
//adoc.CommandText:='sp_dropdevice ''bigconsumer''';
//adoc.Execute;
//end;
end;
 
接受答案了.
 
后退
顶部