各位大侠,我用 sqlserver语句备份数据库发现一个奇怪问题
语句如下:
 qrystr:=' BACKUP DATABASE lsy TO disk='''+tempstr+''''+' with init,stats';qrystr:='use master restore database lsy from disk='''+tempstr+''''+' with Replace ';
现在的问题是
我将 数据库lsy 备份好后
从数据库lsy 中删除一个表yz
然后恢复数据库,按道理数据库中应有表yz
但是没有,想不通
谢谢

解决方案 »

  1.   

    首先谢谢您的帮助
    procedure Tsjwh.BitBtn1Click(Sender: TObject);
      var qrystr,tempstr:string;
    begin
      if trim(bftx1.Text)=''
        then
          begin
            messagebox(handle,pchar('请先输入备份数据库目录!'),pchar('信息!'),64);
            bftx1.SetFocus;
          end
        else
          begin  //1
             qrystr:='';tempstr:='';
             tempstr:=trim(bftx1.Text);
             qrystr:=' BACKUP DATABASE lsy TO disk='''+tempstr+''''+' with init,stats';         adotemp.Close;
             adotemp.SQL.Clear;
             adotemp.SQL.Add(qrystr);
             try
                      adotemp.ExecSQL;
                      messagebox(handle,pchar('数据库备份成功!'),pchar('信息!'),64);
                    except
                      messagebox(handle,pchar('备份数据库失败!'),pchar('信息!'),64);
                    end;
          end;//1end;procedure Tsjwh.BitBtn3Click(Sender: TObject);
      var qrystr,tempstr,tempstr1:string;
          len:integer;
           kg:integer;
    begin
       kg:=0;
       kg:=messagebox(handle,pchar('您确定恢复数据库吗?'),pchar('是否恢复?'),mb_yesNo+mb_iconquestion+mb_defbutton2);   if kg=6
         then
           begin //  恢复1
      if trim(hftx1.Text)=''
        then
          begin
            messagebox(handle,pchar('请先输入备份数据库的目录!'),pchar('信息!'),64);
            hftx1.SetFocus;
          end
        else
          begin  //1
             qrystr:='';tempstr:='';   tempstr1:='';
             tempstr:=trim(hftx1.Text);
             len:=0;
             len:=length(tempstr)-3;
             tempstr1:=copy(trim(hftx1.Text),len,4);
             if tempstr1<>'.bak'
               then
                 begin  //11
                   messagebox(handle,pchar('请输入有效的数据库文件!'),pchar('信息!'),64);
                   hftx1.SetFocus;
                 end//11
               else
                 begin   //22
                    tempstr:=trim(hftx1.Text);
                     qrystr:='use master restore database lsy from disk='''+tempstr+''''+' with Replace ';
                    adotemp.Close;
                    adotemp.SQL.Clear;
                    adotemp.SQL.Add(qrystr);
                    try
                      adotemp.ExecSQL;
                      messagebox(handle,pchar('数据库恢复成功、重新启动程序!'),pchar('信息!'),64);  main.close;                except
                      messagebox(handle,pchar('恢复数据库失败!'),pchar('信息!'),64);
                    end;             end;//22
          end;//1
        end;//恢复2
    end;