我想在一个窗体上的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

解决方案 »

  1.   

    错误提示adoquery4:field '电费率'not found根据提示 是你的表中没有'电费率'这个字段
      

  2.   


    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; 
      

  3.   

    估计是名字写错了,但是你可以先运行你的SQL句子检查下
      

  4.   

    'select * from 住户信息,水电信息表 where 住户信息.住宅号=水电信息表.住宅号  and 住户信息.住宅号 ='''+str1+'''and 住户信息.住户姓名 ='''+str2+''''可以这样。在sql.open之前showmessage(strsql);看看自己的语句是否有问题!