我想要查找符合条件的数据,在Adoquery中用了count(*),并符给一个值,结果是不正常定义了参数对象.
请帮我看看吧.
adoquery1.Close;
adoquery1.SQL.Text := 'select :vcount = count(*) from client where code=:vccode';
adoquery1.Parameters.ParamByName('vccode').Value := trim(CB_CCode.Text);
try
adoquery1.ExecSQL;
except
on e: exception do
begin
MessageDlg(e.Message, mterror, [mbOK], 0);
exit;
end;
end;
li := adoquery1.Parameters.parambyname('vcount').Value;
就是这里取不到li的值啊.
请帮我看看吧.
adoquery1.Close;
adoquery1.SQL.Text := 'select :vcount = count(*) from client where code=:vccode';
adoquery1.Parameters.ParamByName('vccode').Value := trim(CB_CCode.Text);
try
adoquery1.ExecSQL;
except
on e: exception do
begin
MessageDlg(e.Message, mterror, [mbOK], 0);
exit;
end;
end;
li := adoquery1.Parameters.parambyname('vcount').Value;
就是这里取不到li的值啊.
select count(*) as vcount from client where code=:vccode
然后把vcount 像访问正常的字段一样来访问
不会吧
我只用过 count(*) AS vcount
adoquery1.SQL.Text := 'select count(*) as cnt from client where code=:vccode';
adoquery1.Parameters.ParamByName('vccode').Value := trim(CB_CCode.Text);
try
adoquery1.ExecSQL;
except
on e: exception do
begin
MessageDlg(e.Message, mterror, [mbOK], 0);
exit;
end;
end;
返回记录集的第一条记录的cnt字段的值就是结果。