procedure TForm1.Button1Click(Sender: TObject);
begin
  Aqu.Close;
  Aqu.SQL.Add('select id,v_Name from tb_Test where i_State=0 order by id');
  Aqu.Open;
  while not Aqu.Eof do
  begin
    Memo1.Lines.Insert(0,InttoStr(Aqu.Fields(0))+'----'+Aqu.Fields(1));
    Comm.Parameters.Clear;
    Comm.CommandText:='Insert into tb_Test(v_Name) values (:@v_Name);';
    Comm.Parameters.Refresh;
    Comm.Parameters[0].value:= datetimetostr(now);
    Comm.Prepared:=true;
    try
      Comm.Execute;
    except
      memo1.Text:=Comm.CommandText;
    end;
    Comm.Connection.Close;
    Aqu.Next;
  end;
end;

解决方案 »

  1.   

    Insert into tb_Test(v_Name) values (:@v_Name) 
    好好检查下  你这个表中就一个字段吗? 这怎么可以呢? 
      

  2.   

    如果你要更新某个字段的数据就要用update
      

  3.   

    Memo1.Lines.Insert(0,InttoStr(Aqu.Fields(0))+'----'+Aqu.Fields(1));
    这句后面的Aqu.Fields(1)应该改成Aqu.Fields[1].AsString吧?
      

  4.   


    哈哈,这有什么不可以的,我只是测试一下,表中有三个字段ID(自增型),i_State(默认值为0),这不就剩下这一个V_Name字段了吗
      

  5.   

    不错,是这的问题,但现在出现新的问题了,运行到Aqu.Next这里就出错了
      

  6.   

    Comm.Connection.Close; 
    ------------------------
    你把与数据库的链接都断开了,他肯定运行到Aqu.Next这里就出错了把这句话去掉,或者放在while do begin..end之后
      

  7.   

    Comm.CommandText:='Insert into tb_Test(v_Name) values (:@v_Name);';