注册 登录
编程论坛 Delphi论坛

使用ADO插入数据出错

ttkl 发布于 2006-10-16 17:14, 729 次点击

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 .

3 回复
#2
ivanzeng2006-10-25 14:11
字段bh,mc是什么类型?把
Str_S:='Insert into a_doc (bh,mc)values('+Trim(Edtbh.Text)+','+Trim(Edtmc.Text)+')';改为下面的看看
Str_S:='Insert into a_doc (bh,mc)values('+#39+Trim(Edtbh.Text)+#39+',’+#39+Trim(Edtmc.Text)+#39+‘)';
#3
j6682006-12-20 22:21
楼上的。。请问#39是什么意思??
#4
nongen2006-12-21 09:17

chr(39)

1