Delphi 中 adoquery Parameter ‘A’ not found---------半转
来源:互联网 发布:大数据时代的变革 编辑:程序博客网 时间:2024/06/04 21:06
问:adoquery Parameter ‘A’ not found
源码为:
1
2
3
4
5
6
7
8
9
10
11
Query2
.
Close;
Query2
.
SQL
.
Clear;
Query2
.
SQL
.
Add(
'select * From mnyCheckMonth'
);
Query2
.
SQL
.
Add('where mcmCheckId
in
(Select DisTinCt msmCheckId From
mnyServeMonth');
Query2
.
SQL
.
Add(
'Where msmTableId in (Select btaId From basTable'
);
Query2
.
SQL
.
Add(
'Where btaDepartment=:A))'
);
Query2
.
Parameters
.
ParamByName(
'A'
).Value := List[
0
].Text;
//参数[0]也就
是A的值为中文
'服务1部'
//Query2.Parameters.Parameter.Value := List[0].Text;
Query2
.
Open;
答:因为参数A取到了中文值,而Delphi 7的TADOQuery组件毕竟不是ADO原生控件,所
以在传递中文方面存在BUG,所以当Query2的ParamCheck打开为True的时候,中文参数
值会变成乱码,所以造成参数的自动构建失败。所以出现错误:Parameter ‘A’ not
found。
相比而言,BDE的组件TQuery毕竟是Borland的原生控件,在中文参数值传递方面暂时
未发现BUG。
另外还有一个原因,就是当设置主从数据表关系时,动态读取从表数据
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
procedure
TDataModule1
.
ds_customerDataChange(Sender: TObject;
Field: TField);
var
CustomerId:Variant;
begin
try
CustomerId:=qry_customer
.
FieldValues[
'id'
];
qry_yinban
.
Close;
qry_yinban
.
SQL
.
Clear;
qry_yinban
.
SQL
.
Add(
'SELECT * FROM yinban WHERE customer_id=:CustomerId'
);
qry_yinban
.
Parameters
.
ParseSQL(qry_yinban
.
SQL
.
Text,
True
);
qry_yinban
.
Parameters
.
ParamByName(
'CustomerId'
).Value:=CustomerId;
qry_yinban
.
Open;
except
end
;
end
;
解决方面是:关闭ParamCheck为False,这样中文参数传递正确,然后使用
Query2.Parameters.ParseSQL(Query2.SQL.Text, true);强制生成参数对象。
以上为转载,但在实际中我的解决正好相反,是把ParamCheck 属性 设为 True!! 不解...
- Delphi 中 adoquery Parameter ‘A’ not found---------半转
- Parameter xxx not found.
- Delphi AdoQuery
- Delphi中利用ADOQuery连接excel表格
- Delphi中adoquery的两个小问题
- Mybatis异常 Parameter "..." not found
- Mybatis出现Parameter not found
- ADOQuery的Parameter问题
- Parameter not found的出现的原因
- ibatis.binding.BindingException: Parameter 'XXX' not found
- mybatis Parameter 'XXX' not found问题
- Mybatis foreach 问题 Parameter 'item' not found
- Mybatis 参数无法获取Parameter not found
- mybatis报错Parameter '**' not found
- ibatis.binding.BindingException: Parameter 'xxx' not found
- ADOQuery错误:ADOQuery1:commandtext does not return a result set
- ADOQuery错误:ADOQuery1:commandtext does not return a result set
- delphi 中 adoquery 带参数查询的奇怪问题
- android UI
- linux禁止用户远程登录的方法
- 嵌入式系统启动例程
- 职场
- IC卡读卡器测试程序
- Delphi 中 adoquery Parameter ‘A’ not found---------半转
- C/C++反序输出字符串总结
- poj 3470
- 提高Domino服务器性能方法
- SQL Server 通用分页方案
- Python写爬虫——抓取网页并解析HTML
- POJ 2559
- MOTO不相信眼泪!艰难回归!你,准备好了吗?
- 内网、外网IP地址