我从Query2表里统计的数据往Query1表里写数据时会出错:
Query1:Cannot Perform this operation on a closed dataset.
可是按常理Query1本来就要关闭,才能往此数据库写数据,可我弄不清楚这出错是什么原因。
请各大高手们帮帮忙!!!!小弟在此3Q了。

解决方案 »

  1.   

    这是我出错的代码:  time1是统计当前时间是多少分钟; i 是合计费用。   while NOT(Query2.Eof ) do
        begin
            time :=Query2.fieldbyname('DURATION').AsString;
          j:=time1(time);
          s:=s+j;
          Query2.Next;
        end;
            i:=s*strtofloat(edit1.Text); Query1.Close;
     clCont:=combobox2.Text;
     Query1.Edit;
    if clCont='移动网' then
      begin
      Query1.FieldByName('PHONE').AsString:=edit2.Text;
      Query1.FieldByName('YD_TIME').Value := S;
      Query1.FieldByName('YD_COUNT').Value := i;
      Query1.Post;
      Query1.Open;
      

  2.   

    这是我出错的代码:  time1是统计当前时间是多少分钟; i 是合计费用。   while NOT(Query2.Eof ) do
        begin
            time :=Query2.fieldbyname('DURATION').AsString;
          j:=time1(time);
          s:=s+j;
          Query2.Next;
        end;
            i:=s*strtofloat(edit1.Text); Query1.Close;
     query1.open //加这里试试
     clCont:=combobox2.Text;
     Query1.Edit;
    if clCont='移动网' then
      begin
      Query1.FieldByName('PHONE').AsString:=edit2.Text;
      Query1.FieldByName('YD_TIME').Value := S;
      Query1.FieldByName('YD_COUNT').Value := i;
      Query1.Post;
      Query1.Open;
      

  3.   

    我把Query1.Close改成Query1.open就会出现 Query1:Cannot Modify a read-only dataset.
      

  4.   

    你把query1关了,然后又edit当然就会出错了。
    直接把query1.close那句删掉试试
      

  5.   

    Query默認是不能編輯的,將Query1的RequestLive改成True,應該就可以了
      

  6.   

    这是我出错的代码:  time1是统计当前时间是多少分钟; i 是合计费用。   while NOT(Query2.Eof ) do
        begin
            time :=Query2.fieldbyname('DURATION').AsString;
          j:=time1(time);
          s:=s+j;
          Query2.Next;
        end;
            i:=s*strtofloat(edit1.Text); Query1.Close; qurey1.RequestLive:=true;
     query1.open  clCont:=combobox2.Text;
     Query1.Edit;
    if clCont='移动网' then
      begin
      Query1.FieldByName('PHONE').AsString:=edit2.Text;
      Query1.FieldByName('YD_TIME').Value := S;
      Query1.FieldByName('YD_COUNT').Value := i;
      Query1.Post;
      Query1.Open;
      

  7.   

    应该是把query1.open放在clCont:=ComboBox2.text下面,你再试试
      

  8.   

    Query1.Close;
     query1.open 
     qurey1.RequestLive:=true;
    或者直接将query1的requestlive设置为true;