procedure TForm1.Button2Click(Sender: TObject); var aa:integer; begin aa:=strtoint(edit1.Text); adoquery1.close; adoquery1.sql.clear; adoquery1.sql.add('select 密码 from num where id=:aa'); adoquery1.open; if adoquery1.fields[0].value=null then messagebox(form1.handle,'无此记录','错误',mb_ok) else messagebox(form1.handle,'有记录','正确',mb_ok); end; end. 我明明打了个有记录的数(120),但是它说是说“无此记录”??? 不好意思,问题是不是太没有水准了?!
----------------------------------------------
因为笨,所以问!
可以这样试一下: if adoquery1.RecordCount=0 then //无记录 else //有记录 另外下面这条语句中的:是什么意思呢? adoquery1.sql.add('select 密码 from num where id=:aa');
----------------------------------------------
编程之路真如铁,而今迈步从头越
adoquery1.sql.add('select 密码 from num where id=:aa'); adoquery1.Parameters.ParamByName('aa').value:=';//這個參數要賦值? adoquery1.open;
----------------------------------------------
-
adoquery1.sql.add('select 密码 from num where id=:aa'); 你把这句改为: adoquery1.sql.add('select 密码 from num where id=' + aa);
----------------------------------------------
中流一壶,千金争挈。宁为铅刀,毋为楮叶。错节盘根,利器斯别。识时务者,呼为俊杰!