SQL语句问题,大家进来看看。(50分)

  • 主题发起人 mmgoodboy
  • 开始时间
M

mmgoodboy

Unregistered / Unconfirmed
GUEST, unregistred user!
有个表(Table)如下:
ID NAME ADD TEL
1 HENLIN GUANGHZOU 8759415
2 JINHN SHENZHEN 5485554

其中ID是ACCESS中自动增加的编号,通过Edit输入ID,然后写SQL语句。
我是这样写的,select * from Table wehere ID='Edit1.text';可是老是出错。
请问是什么原因。
 
select * from Table wehere ID=Edit1.text不加''
 
where id=:id
parambyanem('id').asinteger:=strtoint(edit1.text)
 
sql.text:='select * from Table wehere ID='+Edit1.text;
 
sqlstr := 'select * from Table wehere ID=' + Edit1.text;
Query1.Execute(sqlstr);
 
同意ugvanxk的答案
 
ID是数值型的
 
对对,忘了id是整型了:)
 
with query1 do begin
close; sql.clear;
sql.add('select * from table where id='+edit1.text);
try open except end;
end
 
同意:twos
 
'select * from Table wehere ID='+Edit1.text
 
select * from table where id='+''''+Edit1.text+''''
 
首先,ID是自增型字段,不需要用引号进行标注。
其次,若有必要,在将edit1.text代入到SQL语句中前,将edit1.text滤去空格。
再次,你的edit1的输入内容必须进行检查,只能接受数字。
 
自增字段不用自已处理,Access会帮你处理。
 
注意:
select * from Table wehere ID='''Edit1.text''''
就可以了.
 
顶部