我想在一个窗体上的edit控件上显示两个不同的表的属性,这两个表具有相同的关键字,
我先做了个连接查询,如果记录不为空则把表的字段属性值加到某个EDIT控件的TEXT属性中
代码如下:if (dbedit1.Text <>'')and(dbedit11.Text <>'') then
begin
str1:=dbedit1.Text ;
str2:=dbedit11.Text ;
strsql:='select * from 住户信息,水电信息表 where 住户信息.住宅号=水电信息表.住宅号 and 住户信息.住户姓名=水电信息表.住户姓名 and 住户信息.住宅号 ='''+str1+'''and 住户信息.住户姓名 ='''+str2+'''';
with ADOQuery4 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOQuery4.RecordCount <> 0 then
begin
edit2.Text := adoquery4.FieldByName('电费率').Value;
edit4.Text := adoquery4.FieldByName('水费率').Value;end;
end;
end;
错误提示adoquery4:field '电费率'not found
我先做了个连接查询,如果记录不为空则把表的字段属性值加到某个EDIT控件的TEXT属性中
代码如下:if (dbedit1.Text <>'')and(dbedit11.Text <>'') then
begin
str1:=dbedit1.Text ;
str2:=dbedit11.Text ;
strsql:='select * from 住户信息,水电信息表 where 住户信息.住宅号=水电信息表.住宅号 and 住户信息.住户姓名=水电信息表.住户姓名 and 住户信息.住宅号 ='''+str1+'''and 住户信息.住户姓名 ='''+str2+'''';
with ADOQuery4 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOQuery4.RecordCount <> 0 then
begin
edit2.Text := adoquery4.FieldByName('电费率').Value;
edit4.Text := adoquery4.FieldByName('水费率').Value;end;
end;
end;
错误提示adoquery4:field '电费率'not found
if (dbedit1.Text <>'')and(dbedit11.Text <>'') then
begin
str1:=dbedit1.Text ;
str2:=dbedit11.Text ;
strsql:='select 住户信息.*,水电信息表.* from 住户信息,水电信息表 where 住户信息.住宅号=水电信息表.住宅号 and 住户信息.住户姓名=水电信息表.住户姓名 and 住户信息.住宅号 ='''+str1+'''and 住户信息.住户姓名 ='''+str2+'''';
with ADOQuery4 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOQuery4.RecordCount <> 0 then
begin
edit2.Text := adoquery4.FieldByName('电费率').Value;
edit4.Text := adoquery4.FieldByName('水费率').Value; end;
end;
end;