AdoQuery.fieldvalues['字段名称'] 为什么是NULL和''的就出出现问题,我是想查出这个字段的说有数据(保持不变)插入到另外的字段中。
提示:could not convert variant of type(null) into type(string)
这个问题怎么解决,多谢!

解决方案 »

  1.   

    if AdoQuery['字段名称'] <> NIL then
      

  2.   

    我不用判断的 我只想把里面的数据取出来 按原来的格式存储到另外的字段中。我不管你是null 和'' 或者其他的数据,还是按原来的格式不变。
      

  3.   

    修改TADOQuery的SQL属性select ..., 字段名称, ...
    改为
    select ..., isnull(字段名称, ''), ...
      

  4.   

    to  dulei115()
       我试了这种方法,还是到为NULl的时候出现问题。就是执行查询位NULL的时候出现问题 。
     to juliens(星星球)
      我就是判断了,adoquery还是要执行查询啊,问题是到为NULL的时候就出错了。
      

  5.   


    stt1:=''''+adoquery1.fieldvalues.['ID']+'''';
    str2:=''''+adoquery1.fieldvalues.['mph']+'''';
    close;
    sql.clear'
    sql.add(insert table(a,b,) values ('+str1+','+str2+'));
    execsql;
      

  6.   

    你这样是有问题,要转换成字符串就这样做:
    stt1:=adoquery1.FieldByName('ID').AsString;
    str2:=adoquery1.FieldByName('mph').AsString;
      

  7.   

    stt1:=quotedstr(vartostr(adoquery1.fieldvalues['ID']));
    str2:=quotedstr(vartostr(adoquery1.fieldvalues['mph']));
    close;
    sql.clear;
    sql.add('insert table (a,b) values ('+str1+','+str2+')');
    execsql;
      

  8.   

    Close;
    SQL.Clear;
    SQL.Add('insert into tablename(a, b) values(:a, :b)');
    if ADOQuery1.FieldByName('ID').IsNull then
      Parameters.ParamByName('a').Value := null
    else
      Parameters.ParamByName('a').Value := ADOQuery1.FieldByName('ID').AsString;
    if ADOQuery1.FieldByName('mph').IsNull then
      Parameters.ParamByName('b').Value := null
    else
      Parameters.ParamByName('b').Value := ADOQuery1.FieldByName('mph').AsString;
    Prepared;
    ExecSQL;