select A from talbe1 where b=text
以上返回的是什么类,如何得到A的字符串类型?

解决方案 »

  1.   

    返回值类型与你选的字段类型一致,比如
    select a,b from table1 where c=..;
    假如a是integer,b是string型
    你可以这样得到他们的值:
    var
      temp1:integer;
      temp2:string;
    temp1:=query1.fieldbyname('a').asinteger;
    temp2:=query1.fieldbyname('b').asstring;
    其他类型类似
      

  2.   

    返回值类型与你选的字段类型一致,比如
    select a,b from table1 where c=..;
    假如a是integer,b是string型
    你可以这样得到他们的值:
    var
      temp1:integer;
      temp2:string;
    temp1:=query1.fieldbyname('a').asinteger;
    temp2:=query1.fieldbyname('b').asstring;
    其他类型类似另外,如果b是string型,但都是数字,也可以这样
    var
      i : integer;i := ADOQuery1.FieldByName('b').AsInteger;
    //前提:不越界~
      

  3.   

    1。select A from talbe1 where b=text
    ft,返回的是一个数据集,而不是类。可以用TDataSet来接受从而实现封装。
    2。在TTable中FieldDef是用来说明字段属性的,包括类型。
      

  4.   

    楼上的兄弟:
     我知道返回的是一个数据集,所以我问如何从数据集中某一记录中A的值?
    帮我看一下:
     var str:string;
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('select A from table1 where B:=text');
    adoquery1.open;
    str:=adoquery1.fieldbyname('A').asstring;
      

  5.   

    SQL里面怎么会有Delphi的“:=”号?应该是
    adoquery1.sql.add('select A from table1 where B=text');再有,如果text是个字串型,则应该写为
    adoquery1.sql.add('select A from table1 where B=''' + text + '''');好了,再试试!
      

  6.   

    adoquery1.sql.add('select A,B from table1 where B=''' + text + '''');adoquery1.open;
    你这样试一试