procedure TfrmMain.RestoreDataBase;
var
CmdStr,
Paths:String;
begin
Paths:=Extractfilepath(Application.ExeName);
if fileexists(ConCat(Paths,\'数据库文件名称\')) then
try
CmdStr:=\'ISQL -E -Q "if (select Count(*) from sysdatabases where name=%s)=0 EXEC sp_attach_db @dbname = N%s,@filename1 = N%s,@filename2 = N%s"\';
CmdStr:=format(CmdStr,[ConCat(#39,\'NGISdbms\',#39),
ConCat(#39,\'数据库名称\',#39),
ConCat(#39,Paths,\'数据库文件名称\',#39),
ConCat(#39,Paths,\'数据库日志文件名称\',#39)]);
WinExec(PChar(CmdStr),0);
except
on E:Exception do
Logmemo.Add(e.Message);
end;
end;
var
CmdStr,
Paths:String;
begin
Paths:=Extractfilepath(Application.ExeName);
if fileexists(ConCat(Paths,\'数据库文件名称\')) then
try
CmdStr:=\'ISQL -E -Q "if (select Count(*) from sysdatabases where name=%s)=0 EXEC sp_attach_db @dbname = N%s,@filename1 = N%s,@filename2 = N%s"\';
CmdStr:=format(CmdStr,[ConCat(#39,\'NGISdbms\',#39),
ConCat(#39,\'数据库名称\',#39),
ConCat(#39,Paths,\'数据库文件名称\',#39),
ConCat(#39,Paths,\'数据库日志文件名称\',#39)]);
WinExec(PChar(CmdStr),0);
except
on E:Exception do
Logmemo.Add(e.Message);
end;
end;