我只会使用SQL Server,备份是Backup Database,不只在mysql下是否能用?

解决方案 »

  1.   

    这没有关系,只要如何实现我说的备份就行,用savedialog如何将以有的某个表拷到其它任何地方进行备分即可
      

  2.   

    不是写在程序里总要给用户有个直观的感觉吧,有一个savedialog这相比较清晰一点,
      

  3.   

    type
    TMethod=Record
        pp:string[1];//标识是存ys1+bh还是ys2+bh
        xh:string[3];
        bh:string[12];
        fb:string[8];
        mc:string[56];
        dw:string[8];
        q:string[13];
        jj:string[13];
        rg:string[13];
        jx:string[13];
        qs:string[8];
        xs:string[8];
        xsa:string[8];
        xsb:string[8];
        xsc:string[8];
        hsgs:string[254];
        hss:string[254];
       end;
      methodfiletype=file of TMethod;
    var
    methodfile:methodfiletype;
       methodrec:TMethod;
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
    if savedialog1.Execute then
       filename1:=savedialog1.FileName
    else
       exit;
          tabname1:='ys1'+bh;
         assignfile(methodfile,filename1);
            rewrite(methodfile);
        with datamodule1.Query1 do
           begin
           close;
           sql.Clear;
           sql.Add('select * from '+tabname1+''); //
           open;
          first;
          i:=0 ;
          while not eof do
            begin
             methodrec.pp:='1';
             methodrec.xh:=fieldbyname('xh').asstring;
             methodrec.bh:=fieldbyname('bh').AsString;
             methodrec.fb:=fieldbyname('fb').AsString;
             methodrec.mc:=fieldbyname('mc').AsString;
             methodrec.dw:=fieldbyname('dw').AsString;
             methodrec.q:=floattostr(fieldbyname('q').AsFloat);
             methodrec.jj:=floattostr(fieldbyname('jj').AsFloat);
             methodrec.rg:=floattostr(fieldbyname('rg').AsFloat);
             methodrec.jx:=floattostr(fieldbyname('jx').AsFloat);
             methodrec.qs:=floattostr(fieldbyname('gs').AsFloat);
             methodrec.xs:=floattostr(fieldbyname('xs').AsFloat);
             methodrec.xsa:=floattostr(fieldbyname('xsa').AsFloat);
             methodrec.xsb:=floattostr(fieldbyname('xsb').AsFloat);
             methodrec.xsc:=floattostr(fieldbyname('xsc').AsFloat);
             methodrec.hsgs:=fieldbyname('hsgs').AsString;
             methodrec.hss:=fieldbyname('hss').AsString;        seek(methodfile,i);
            i:=i+1;
            write(methodfile,methodrec);
             next;
            end;
            end;
      

  4.   

    type 定义的一些字符串数组是什么东西啊? 你自己表的字段?
      

  5.   

    pp,xh,bh等对应表中的字段,其中pp[1],xh[]等数组的大小与字段长度对应
      

  6.   

    这样子对某个表进行备份不太好吧,这样的话用batchmove不也一样吗?
      

  7.   

    var
         
         filename:string;//目标库文件名
         source,target: TFileStream;
         
    begin
         
         source:=TFileStream.Create('源库文件名',fmOpenRead );//支持路径、扩展名;
         try
           target:=TFileStream.Create(filename,fmOpenWrite or fmCreate);
           try
             if target.CopyFrom(source,source.Size)=source.Size then
               ShowMessage('成功备份到'+filename+'!!!');
           finally
             target.Free;
           end;
         finally
           source.Free;
         end;
      

  8.   

    begin
        pgbar.Max:=100;
        pgbar.Min:=0;
        pgbar.Step:=20;
         adoconnection1.Close;
         if adoconnection1.Connected then
         begin
            application.MessageBox('数据库数据正在使用','系统提示')
         end
         else
              begin
              try
                adocommand1.CommandText:='use master';
                pgbar.StepIt;
                adocommand1.Execute ;
                adocommand1.CommandText:='execute sp_helpdevice';
                pgbar.StepIt;
                adocommand1.Execute ;
                pgbar.stepit;
                adocommand1.CommandText:='backup database docmanage to disk=''c:\ccc.bak'' with init';
                pgbar.StepIt;
                adocommand1.Execute ;
                adocommand1.CommandText:='backup log docmanage to ccc';
                pgbar.StepIt;
                adocommand1.Execute;
                try
                   aDOConnection1.Connected:=true;
                except
                  ShowMessage('无法连接指定的数据库!');
                  application.Terminate;
                end;
                form1.Hide;
                  if messagedlg('数据库docmanage已成功备份到c:\ccc.bak!是否继续?',mtwarning,[mbok],0)=mrok then
                     begin
                       form1.close
                     end;
              except
                 on exception do
                     if ADOConnection1.InTransaction then
                         ADOConnection1.RollbackTrans
    end;
    end;
    end;