SQL数据库恢复

var S:String;
begin
   try
     ADOC.Close;
     if WINSA.checked then ADOC.connectionstring:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source='+Edit1.text else
     ADOC.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+Edit2.text+';Initial Catalog=master;Data Source='+Edit1.text+';password='+Edit3.text;
     S:=StringReplace(ADOC.ConnectionString,'master','EASY_GAS',[rfReplaceAll, rfIgnoreCase]);
     WriteINIStr('网络设置','数据库连接字符',S);
     ADOC.Open;
     ADOCOMM.commandtext:='RESTORE DATABASE EASY_GAS FROM DISK = '+#39+Edit4.text+#39+' WITH MOVE '+#39+'EASY_GAS_data'+#39+' TO '+#39+DBPATH.text+'EASY_GAS_NOW.mdf'+#39+', MOVE '+#39+'EASY_GAS_log'+#39+' TO '+#39+DBPATH.text+'EASY_GAS_NOW.ldf'+#39;
     ADOCOMM.Execute;
     Showmessage('数据库恢复成功,'+#13+'原数据库已恢复!');
   Except
     Showmessage('数据库恢复失败!');
     Exit;
   end;
     Close;
end; 

你可能感兴趣的:(SQL数据库恢复)