为什么有错误:Query1:Field 'Mybh' is of an unknown type.(0分)

  • 主题发起人 delphi_hzj
  • 开始时间
D

delphi_hzj

Unregistered / Unconfirmed
GUEST, unregistred user!
var Mybh:string;
begin
Mybh:=edit1.text;
Query1.SQL.text:='select sum(je) as Myje from cd.dbf where Bh=:mybh';
query1.open;
edit11.text:=query1.fieldByname('Myje').asstring;
query1.close;
end;

以上代码在试运行时。为什么有错误:Query1:Field 'Mybh' is of an unknown type.
 
Query1.SQL.text:='select sum(je) as Myje from cd.dbf where Bh=mybh';
 
参数赋值了吗?
 
Query1.close;
Query1.sql.clear;
Query1.sql.add(''select sum(je) as Myje from cd.dbf where Bh='''+mybh+'''');
Query1.open;
你试试!
 
去掉var mybh:string;的变量声明
begin
Query1.SQL.text:='select sum(je) as Myje from cd.dbf where Bh=:mybh';
Query1.ParamByName('mybh').AsString:=Trim(Edit1.Text);
query1.open;
 
Query1.SQL.text:='select sum(je) as Myje from cd.dbf where Bh=''''mybh''''';
 
前些日子这里我上不来了,没给大家回贴,不好意思。
谢谢。问题解决了。
 
顶部