注册 登录
编程论坛 Delphi论坛

急,数据库方面,adoquery查询

weimingqing 发布于 2005-07-09 22:04, 1491 次点击
adoquery1.close;
  adoquery1.SQL.Clear;
  adoquery1.SQL.Add('select * from puplic ' );
  adoquery1.SQL.Add('where 姓名=:p_name');
  adoquery1.parameters.ParamByName('p_name').Value:=edit5.Text;
  adoquery1.open;
各位想请教一下
 我用这段程序来查询表,当按F9运行后,在第一次在EDIT5.TEXT中输入查询参数,查询成功后。当我第二次再输入参数时,再查询时就出错了,具体错误信息是“project project2 exe raised exception class EOLeException with message'FROM子句语法错误。‘”,process stopped Use Step or Run to continue.
   诚请指教!!!!!1急
具体的文件在文件上传上。
3 回复
#2
wolf2005-07-15 17:02
adoquery1.SQL.Add('where 姓名=:p_name');
  adoquery1.parameters.ParamByName('p_name').Value:=edit5.Text;

应该是这两句有问题,换一种更好的写法吧
#3
dj8592005-07-23 23:01
应该这样写
adoquery1.close;
  adoquery1.SQL.Clear;
  adoquery1.SQL.Add('select * '+
                                   ' from puplic '+
                                   ' where 姓名=:p_name');
  adoquery1.parameters.ParamByName('p_name').Value:=edit5.Text;
  adoquery1.open;
这样应该没问题了,试试吧
#4
killtry2005-09-09 11:29
adoquery1.close;
  adoquery1.SQL.Clear;
  adoquery1.SQL.Add('select * from puplic ' );
  adoquery1.SQL.Add('where p_name='''+edit5.Text+'''');
adoquery1.open;
1