adoquery1.Close;
adoquery1.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=check';
try
with adoquery1 do
begin
 close;
 sql.Clear;
 sql.Add('backup database check to disk='''+DestinationPath.Caption+'\'+edit1.text+'.bak'' with init');
 Execsql;
  end;
  showmessage('备份完成。');
end;
运行时错误提示“check附近有语法错误”。请高手指点

解决方案 »

  1.   

    adoquery1.Close;
    adoquery1.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=check';
    try
    with adoquery1 do
    begin
     close;
     sql.Clear;
     sql.Add('backup database [check] to disk='''+DestinationPath.Caption+'\'+edit1.text+'.bak'' with init');
     Execsql;
      end;
      showmessage('备份完成。');
    end;
      

  2.   

    因为check是SQLSERVER数据库的关键字,所以作为表名的话要加[check]