主题:求助:使用ADO插入数据出错
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from a_doc where bh='''+Trim(Edtbh.Text)+'''');
ADOQuery2.Open;
if ADOQuery2.RecordCount>0 then
begin
application.MessageBox('编号重复!','提示信息',mb_ok+mb_iconinformation);
Edtbh.SetFocus;
exit;
end;
Str_S:='Insert into a_doc (bh,mc)values('+Trim(Edtbh.Text)+','+Trim(Edtmc.Text)+')';
ADOQuery2.Close;// 出错
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add(Str_S);
ADOQuery2.ExecSQL;
运行出现错误提示:
Either Eof or Bof is True,or the Current record has been deleted.Requeseted opration requires a Current record .
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from a_doc where bh='''+Trim(Edtbh.Text)+'''');
ADOQuery2.Open;
if ADOQuery2.RecordCount>0 then
begin
application.MessageBox('编号重复!','提示信息',mb_ok+mb_iconinformation);
Edtbh.SetFocus;
exit;
end;
Str_S:='Insert into a_doc (bh,mc)values('+Trim(Edtbh.Text)+','+Trim(Edtmc.Text)+')';
ADOQuery2.Close;// 出错
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add(Str_S);
ADOQuery2.ExecSQL;
运行出现错误提示:
Either Eof or Bof is True,or the Current record has been deleted.Requeseted opration requires a Current record .