查找语句莫名出错(50分)

  • 主题发起人 主题发起人 ApolloHui
  • 开始时间 开始时间
A

ApolloHui

Unregistered / Unconfirmed
GUEST, unregistred user!
with adoquery4 do
begin
close;
sql.Clear;
sql.Add('select 单位工程号 from 单位工程表 where 单位工程名称='+''''+f0+'''');
execsql;
open;
end;

dwgch:=adoquery4.Fields.Fields[0].AsInteger;

with adoquery4 do
begin
close;
sql.Add('select 楼层号 from 楼层表 where 单位工程号='+inttostr(dwgch)+'and 楼层名称='+''''+f1+'''');
execsql;
open;
end;
光是第一个查询不出问题,一加上第二个提示两面三个都有错呀。哪位大虾帮瞅瞅呀!大分相送
 
with adoquery4 do
begin
close;
sql.Clear;
sql.Add('select 单位工程号 from 单位工程表 where 单位工程名称='+''''+f0+'''');
execsql;
open;
end;
这里去掉ececsql就可以了
delphi中,select语句要用open的,其他插入或者删除的用execsql
 
哪个帮看看呀。很容易的分地呀。[:(!]
 
老提示select语句出错呢。我试试,谢先。
 
不中呀,帮再看看是哪毛病,只第一个查询没问题的。
 
呵呵,不好意思,第二个里少个sql.clear;粗心了。
 
with adoquery4 do
begin
close;
sql.Clear;
sql.Add('select 单位工程号 from 单位工程表 where 单位工程名称='''+f0+'''');
open;
end;

dwgch:=adoquery4.Fields.Fields[0].AsInteger;

with adoquery4 do
begin
close;
sql.Clear;
sql.Add('select 楼层号 from 楼层表 where 单位工程号='+inttostr(dwgch)+'and 楼层名称='''+f1+'''');
open;
end;
 
字段最好是不要用中文
with adoquery4 do
begin
close;
sql.Clear;
sql.Add('select 单位工程号 from 单位工程表 where 单位工程名称='''+f0+'''');
open;
end;

dwgch:=adoquery4.Fields.Fields[0].AsInteger;

with adoquery4 do
begin
close;
sql.Clear;
sql.Add('select 楼层号 from 楼层表 where 单位工程号='+inttostr(dwgch)+'and 楼层名称='''+f1+'''');
open;
end;
 
select 语句后用open
update ,insert ,delete 用EXECSQL
 
后退
顶部