unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBXpress, FMTBcd, StdCtrls, DB, SqlExpr, Provider, Grids,
DBGrids, DBClient, DBLocal, DBLocalS;
type
TForm1 = class(TForm)
SQLCn: TSQLConnection;
Button1: TButton;
C: TSQLClientDataSet;
TmpCn: TSQLConnection;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
d: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var SQL,FileName,s:string;
R:integer;
begin
s:='';
d.InitialDir :='C:/';
d.Filter :='*.mdb|*.mdb';
d.Title :='OKOKOKOKO';
d.Execute ;
FileName:=d.FileName;//获取的文件名字与路径
C.Close ;
SQLcn.Close;
TmpCn.Close ;
//tmpcn.ExecuteDirect( 'ALTER DataBase IcSaler SET SINGLE_USER ');//这句时死机
SQL:='restore database test2 from disk='+''''+FileName+'''';
R:=TmpCn.ExecuteDirect(SQL);
Showmessage('R='+Inttostr(R));
tmpCN.Open ;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SQLCn.Connected := True;
end;
end.