我用table1来插入数据用insert,操作数据,然后post接着关闭table1
当运行后数据存入了数据库中可是重启后数据就不见了为什么啊?

解决方案 »

  1.   

    table的cachedupdates属性你是怎么设置的?
      

  2.   

    下面是我以前用Query1的用法。现在改用table1,还是会出错?
    不过有的时候好像又是对的郁闷procedure TfrmMain.PanelTClick(Sender: TObject);
    var
      sStr ,sStr1, sStr2, sStr6  :String;
      sStr3, sStr4, sStr5        :String;
      Flag                       :boolean;
    begin
       sStr   := copy((Sender as Tpanel).Name , 2, 4);
       sStr1  := cbRoomType.Text;
       sStr2  := cbToward.Text;
       sStr3  := cbPrice.Text;
       sStr4  := cbDiscount.Text;
       sStr5  := copy(cbRoomType.Text, Pos('(',cbRoomType.Text) + 1 , 2);
       sStr6  := cbStatus.Text;
       Flag   := false;
       Query2.SQL.Clear;
       Query2.SQL.Add('Select * from Room');
       Query2.Open;
       while not Query2.Eof do
         begin
           if Query2['RoomNo'] = sStr
             then Flag := true;
           Query2.Next;
         end;
       if not Flag
         then begin
           Query1.Active      := true;
           Query1.RequestLive := true;
           Query1.First;
           Query1.Insert;
           Query1['RoomNo']    := sStr;
           Query1['RoomType']  := copy(sStr5,1,10);
           Query1['CRoomType'] := sStr1;
           if sStr6 <> 'OK(O)'
             then Query1['Status'] := copy(sStr6,1,4)
             else Query1['Status'] := copy(sStr6,1,2);
           Query1['Toward']    := sStr2;
           Query1['Price']     := sStr3;
           Query1['Discount']  := sStr4;
           Query1.Post;
           Query1.Close;
         end
         else begin
           Query1.Active      := true;
           Query1.RequestLive := true;
           Query1.First;
           Query1.Edit;
           Query1['RoomNo']    := sStr;
           Query1['RoomType']  := copy(sStr5,1,10);
           Query1['CRoomType'] := sStr1;
           if sStr6 <> 'OK(O)'
             then Query1['Status'] := copy(sStr6,1,4)
             else Query1['Status'] := copy(sStr6,1,2);
           Query1['Toward']    := sStr2;
           Query1['Price']     := sStr3;
           Query1['Discount']  := sStr4;
           Query1.Post;
           Query1.Close;
         end;
       sStr := copy(sStr6,Pos('(',sStr6) + 1,1);
       (Sender as TPanel).Caption := sStr; //copy((Sender as TPanel).Name,2,4);
    end;