各位大虾,小弟学了一年多的DELPHI,现在想试一下数据库库的备份与恢复,可是总出错,帮忙好吗.咋办呢?
我用的是ACCESS数据库,ADO连接.点BUTTON1时,提示出错:"无效的SQL语句,期待delete,update,select ",到底哪出错了?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TForm1 = class(TForm)
ado: TADOConnection;
ad: TADOQuery;
DataSource1: TDataSource;
od: TOpenDialog;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
fn:string;
begin
if od.Execute then
fn:=od.FileName;
ad.Close;
ad.SQL.Clear;
ad.SQL.Add('restore database db1 from disk='+''''+fn+'''');
try
ado.Connected:=true;
ad.ExecSQL;
except
showmessage('there is something wrong.');
end;
end;
end.