运行以下代码: strStyle := '' ;
strText := '' ; strStyle := ComboBox1.text ;
strText := Trim(Edit1.text) ; AdoQuery1.Close ;
//ADOQuery1.Prepared := True ;
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select * from book where strStyle=:strText') ; //*****
ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
ADOQuery1.Open ;报错:“ ADOQuery1 : Parameter 'strStyle' not found ”在执行到 ***** 处时,我把鼠标置于 SQL 上,显示的为:“ ADOQuery1.SQL =() ”,
这是什么原因?
strText := '' ; strStyle := ComboBox1.text ;
strText := Trim(Edit1.text) ; AdoQuery1.Close ;
//ADOQuery1.Prepared := True ;
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select * from book where strStyle=:strText') ; //*****
ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
ADOQuery1.Open ;报错:“ ADOQuery1 : Parameter 'strStyle' not found ”在执行到 ***** 处时,我把鼠标置于 SQL 上,显示的为:“ ADOQuery1.SQL =() ”,
这是什么原因?
解决方案 »
- delphi上传文件到ftp,
- TreeView问题:如何判断节点a是否处于节点B之下?
- 关于WISE制作安装程序的问题?
- widestring 中数据如何弄到 array [0..100] of widechar 里面??
- HELP!一个小规模的系统(不到10台机子),用什么数据库好呢?ACCESS可不可以?
- 初学者怎么办
- 我的小软件升级了!欢迎大家下载使用,并提供宝贵意见。
- 那位能详细讲一讲用spcomm控件发送、接收信息的流程??
- 有谁用过环保卫士吗?
- 请告诉我如何在ClientDataSet组件中对字段添加总和的详细步骤
- 遇上个网友,她给我出了个问题,如果我在三次之内答对的话,她就做我的临时情人.我已失败两次了.大家来帮我看看这个问题.
- 请教如何用最低的系统资源实现这个问题....
ADOQuery1.Parameters.ParamByName('strText').Value
ADOQuery1.SQL.Add('select * from book where
strStyle=:strText') ;
ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
应该改成:
ADOQuery1.Parameters.ParamByName('strText').value:=strStyle ;
ADOQuery1.Parameters.ParamValues('strStyle').value:=strStyle ;
且ADOQuery1.Parameters中参数名称应为strText
右键,选Add All Fields。
你的数据库有strStyle这个字段吗?
ADOQuery1.SQL.Add('select * from book where ‘+strStyle+‘=:strText')
而且你根本就沒有定義strStyle;strText這兩個為局部變量;
你應該在begin上面用var來定義;
還有你的數據庫里面可能沒有strstyle和strtext這兩個字段吧
where 后面應該跟的是field1=:fieldNew1 and field2=:fieldNew2
然后再用adoquery1.Parameters.ParamByName('fieldNew1').asstring:=combobox1.text;
且在执行时 strStyle 以被赋值为 bookname
我的数据库上是有 bookname 字段
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select * from book where '+strstyle+'='+''''+strtext+'''');
ADOQuery1.Open ;
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select * from book where '+ strStyle+'=:strText') ;
ADOQuery1.Parameters.ParamByName('strtext').value:=strtext ;
ADOQuery1.Open ;
//ADOQuery1.Prepared := True ;
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select * from book where strStyle=:strText') ; //*****
ADOQuery1.Parameters.ParamByName('strStyle').datatype:=ftstring ;
ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
ADOQuery1.Open ;
AdoQuery1.Close ;
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select * from book where strStyle=:strStyle') ; //*****
ADOQuery1.Parameters.ParamByName('strStyle').datatype:=ftstring ;
ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
ADOQuery1.Open ;