我曾经这样:
query.sql.add('backup database 数据库 to disk="'+getcurrentdir+EDIT.text+'"');
但是抱错
以前好象在CSDN上有过类是问题
请问那为大哥能告诉我怎么做啊
(在线等代,ADO和BDE的都可以)

解决方案 »

  1.   

    备份
    Backup DataBase 数据库名 to disk = 备份的磁盘位置('c:\test.bak')
    恢复数据库
    restore database 数据库名 from disk= 恢复的磁盘位置('c:\test.bak')
      

  2.   

    Query.Close;
    Query.SQL.ADD('Backup DataBase 数据库名 to disk = 备份的磁盘位置('c:\test.bak')');
    Query.ExecSQL
      

  3.   

    引号
    query.sql.add('backup database 数据库 to disk='''+getcurrentdir+EDIT.text+'''');
      

  4.   

    要用ADO才行,若用BDE在使用时不能做备份
      

  5.   

    query.sql.add('backup database YOURDATABASENAME to disk='''+BACAUPDIR+EDIT.text+'''');
      

  6.   

    firetoucher(风焱) ,能运行但是不能备份
      

  7.   

    query.sql.Text:='backup database 数据库 to DISK='+''''+'c:\bf'+''''+'  WITH INIT';
      

  8.   

    qlq111213(qinliqin) 
     windwather() 
     firetoucher(风焱) 
    正确
      

  9.   

    备份如下:
            try
                backupString := 'BACKUP DATABASE [Paper] TO  DISK = N'''+edit1.Text+''' WITH  INIT ,  NOUNLOAD ,  NAME = N''Paper 备份'',  NOSKIP ,  STATS = 10,  NOFORMAT';
                adoquery1.Close;
                adoquery1.SQL.Clear;
                adoquery1.SQL.Add(backupString);
                ADOQuery1.Prepared;
                adoquery1.ExecSQL;
                application.MessageBox('备份成功。','提示',0);
            except
                application.MessageBox('备份出错!请重新备份数据。','出错',0);
            end;
    还原如下:
                if opendialog1.Execute then
                begin
                    try
                        adoquery1.Close();
                        adoquery1.SQL.Clear;
                        adoquery1.SQL.Add('use master');
                        adoquery1.Prepared;
                        adoquery1.ExecSQL;
                        restorestring := 'RESTORE DATABASE [Paper] FROM  DISK = N'''+opendialog1.FileName+''' WITH  FILE = 1,  NOUNLOAD ,  STATS = 10,  REPLACE,RECOVERY';
                        self.ADOCommand1.CommandText := restoreString;
                        adocommand1.Execute;
                        application.MessageBox('还原数据成功','提示',0);                    adoquery1.Close();
                        adoquery1.SQL.Clear;
                        adoquery1.SQL.Add('use paper');
                        adoquery1.Prepared;
                        adoquery1.ExecSQL;          
                    except
                        application.MessageBox('还原数据出错!请重新还原,并停止一切的数据操作!','提示',0);
                    end;
                end;