现在已经将adoconnection1,和adoquery1都设置好了.要求在Edit1里面输入一个号码.然后点击一个button查询access数据库里的一个djj表,看这个号码是否存在.下面是我写的代码.为什么不行啊?
moduledata.ADOQuerydjj.close;
moduledata.ADOQuerydjj.SQL.clear;
moduledata.ADOQuerydjj.SQL.Add('select * from djj where 代金券编号= '''+edit1.text+'''');
// adoquery1.ExecSQL;
moduledata.ADOQuerydjj.open;
showmessage(edit1.Text);
if moduledata.ADOQuerydjj.RecordCount=0 then begin
{// showmessage('无此号'+Edit1.Text);
for i:=0 to 5 do
cipherdata2011.BeeperERROR(1);
cipherdata2011.Show(1,'error');
listbox2.Items.Add(strtmp);
end;}
注:我使用了moduledata.这两个控件都在那里面.
各位大哥,能不能帮我看看啊.
moduledata.ADOQuerydjj.close;
moduledata.ADOQuerydjj.SQL.clear;
moduledata.ADOQuerydjj.SQL.Add('select * from djj where 代金券编号= '''+edit1.text+'''');
// adoquery1.ExecSQL;
moduledata.ADOQuerydjj.open;
showmessage(edit1.Text);
if moduledata.ADOQuerydjj.RecordCount=0 then begin
{// showmessage('无此号'+Edit1.Text);
for i:=0 to 5 do
cipherdata2011.BeeperERROR(1);
cipherdata2011.Show(1,'error');
listbox2.Items.Add(strtmp);
end;}
注:我使用了moduledata.这两个控件都在那里面.
各位大哥,能不能帮我看看啊.
如果还要查询djj表里的最后一个字段'是否消费'的布尔值,如果是真则showmessage('此卡已消费');
moduledata.ADOQuerydjj.SQL.clear; moduledata.ADOQuerydjj.SQL.Add('select * from djj where 代金券编号 = '''+edit1.text+'''');
moduledata.ADOQuerydjj.open;//if moduledata.adoquerydjj.isempty=true then
if moduledata.ADOQuerydjj.Eof=true then //上面两句换哪一句都是一样的.
begin //当数据表里没有这个号码时便叫
showmessage('无此号'+Edit1.Text);
for i:=0 to 5 do //控制其它东西叫.
cipherdata2011.BeeperERROR(1);
cipherdata2011.Show(1,'error');
// listbox2.Items.Add(strtmp);
end;
// 可是数据表里确实有这个号码.
注:数据是扫描进去的.但在edit1.text里可以看到这个数据.并且存在于数据表里.
请问哪位大侠知道为什么?
换成
if moduledata.ADOQuerydjj.RecordCount<>0 then begin
并且当数据是扫描进去的,就一定要用这个,但不是扫进去的.可以用
moduledata.ADOQuerydjj.SQL.Add('select * from djj where 代金券编号= '''+edit1.text+'''');
当数据是扫描进去的时候就要用:
moduledata.ADOQuerydjj.SQL.Add('select * from djj where 代金券编号= '''+trim(edit1.text);