我查看了一个表,然后向其中插入一条记录后,想刷新但就出错,
代码如下: if (Button1.Caption='显示') then  
    begin
    
      DataModule3.Query1.Active:=false;
      DataModule3.Query1.Prepare();
       DataModule3.Query1.Active:=true;
       form1.Button1.Caption:='刷新';
      
    end
    else if (form1.Button1.Caption='刷新')//在数据插入后,名字改为‘刷新’
    then
       begin
       
       DataModule3.Query1.Active:=false;
       
       DataModule3.Query1.Prepare();
       DataModule3.Query1.Active:=true;//是这里出错,为什么
        end;
   end;

解决方案 »

  1.   

    query1的sql语句你的内容是什么?
      

  2.   


     if (Button1.Caption='显示') then  
        begin
        
          DataModule3.Query1.Active:=false;
          DataModule3.Query1.Prepare();
           DataModule3.Query1.Active:=true;
           form1.Button1.Caption:='刷新';
          
        end
        else if (form1.Button1.Caption='刷新')//在数据插入后,名字改为‘刷新’
        then
           begin
           
           DataModule3.Query1.Active:=false;
           
           DataModule3.Query1.Prepare();
           DataModule3.Query1.Active:=true;//是这里出错,为什么
            end;
     //  end;这个是不是多了?
      

  3.   

    不好意思,
    我昨天有事老早就关了
    SQL里的语句就是简单的查询语句
    'select * from tool'
      

  4.   

    错误提示是什么?datamodule3.query1.close;
    datamodule3.open;试试
      

  5.   

    更正  datamodule3.open;   ---〉  datamodule3.query1.open
      

  6.   

    晕,我现在刚查到我那里犯的错误
    我在插入数值的时候,已经把SQL语句改了,刷新的时候SQL语句只是执行插入语句,怪不得没有结果呢!
    半天的时间才查出,郁闷!