首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi where附近有异常

2012-10-17 
delphi where附近有错误小生愚昧,实在找不出错误with adoquery1 dobeginclosesql.Clearsql.Add(select

delphi where附近有错误
小生愚昧,实在找不出错误

with adoquery1 do
begin
  close;
  sql.Clear;
  sql.Add('select * for 表明 where 商品编号='''+Edit1.Text+'''');
  open;
  if adoquery1.RecordCount>0 then
  begin
  showmessage('编号重复');
  edit1.SetFocus;
  end;
end
就是一个判断编号是否重复

[解决办法]

Delphi(Pascal) code
sql.Add('select * from 表明 where 商品编号='''+Edit1.Text+'''')
[解决办法]
估计是表名或字段名不正确。另外,用引号去括着引号不是个好的方法,很容易出错,建议这样:
Delphi(Pascal) code
with adoquery1 dobegin  close;  sql.Text='select * for 表名 where 商品编号 = '+QuotedStr(Edit1.Text);  open;  if RecordCount>0 then   begin    showmessage('编号重复');    edit1.SetFocus;  end;end; 

热点排行