参数查询提示 parameter 'A' not found

viano 2008-03-21 08:17:33

代码如下:

ADOQuery2.Close;
ADOQuery2.sql.Clear;
sSql := 'select count From xxzb where kpr=:A ';

ADOQuery2.SQL.Add(sSql);
ADOQuery2.Parameters.ParamByName('A').Value:=DBComboBox1.Text;
ADOQuery2.Open;
Label5.Caption:=ADOQuery2.FieldByName('count').AsString;

请问是什么问题?
...全文
762 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
GDTOPONE 2008-03-21
  • 打赏
  • 举报
回复
一个问题归一个问题
S_Slan 2008-03-21
  • 打赏
  • 举报
回复
[/
with qry1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from employee where fname like'+ ':fname');
Parameters.AddParameter;
Parameters[0].DataType:=ftString;
Parameters[0].Direction:=pdInput;
Parameters[0].Size:=20;
Parameters[0].Value:='p';
Open;
end;[code=Delphi(Pascal)]
viano 2008-03-21
  • 打赏
  • 举报
回复
应该是这样的:



with ADOQuery2 do begin
close;
sql.Text:='select count(pid) as count_id from xxzb where kpr=:a';
Parameters.ParamByName('A').Value:=DBComboBox1.Text;
open;
Label5.Caption:=Fields[0].Value;
end;


呵呵是 count 那里出错了!

打扰你了,还是要给你给分

有个问题再请教一下:

我得 dbcombobox 只能显示一条数据记录 其他的不能被显示

请问如果要显示数据库里面一个字段的所有内容并且能产生下拉框

是不是用 dbcombobox 还是其它 ?

如何使用?


http://topic.csdn.net/u/20080321/21/1bd98135-6a37-4a3e-a57c-6df454f2a9df.html
viano 2008-03-21
  • 打赏
  • 举报
回复
不合适
GDTOPONE 2008-03-21
  • 打赏
  • 举报
回复

with ADOQuery2 do begin
close;
sql.Text:='select [count] from xxzb where kpr=:a';
Parameters.ParamByName('A').Value:=DBComboBox1.Text;
open;
Label5.Caption:=Fields[0].Value;
end;

GDTOPONE 2008-03-21
  • 打赏
  • 举报
回复
注意SQL语句入面的关键字,朋友

with ADOQuery2 do begin
close;
sql.Text:='select [count] from xxzb where x_a=:a';
Parameters.ParamByName('A').Value:=DBComboBox1.Text;
open;
Label5.Caption:=Fields[0].Value;
end;

2,498

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧