大概是关于数据库的问题:
程序运行起来出错误提示“Invalid variant type conversion.”
大家估计一下哪里出错了?如何解决呢?等待中……

解决方案 »

  1.   

    可能是引用字段值不正确,如企图将一个整形字段的值直接赋给string.
     s := Field1.Value;  改为s := Field1.AsString;
      

  2.   

    或者企图将一个string直接赋给整形字段的值
      

  3.   

    to  chutian(我很丑???) 
    圣诞快乐!感谢回复!
    -----------------------------------------------------
      if cdsTemp.FieldByName('shrq').Value <> Null then
       begin
          ……
       end;
    ------------------------------------------------------
    上面一段程序cdsTemp.FieldByName('shrq').Value 不等于
    写成Null提示Undeclared identifier:'null'
    写成''提示“Invalid variant type conversion.”
    //cdsTemp:tclientdataset继续 ……
      

  4.   

    to  maozefa(之源) :
    圣诞快乐!感谢回复!
    ______________________________
    shrq的字段类型是datetime.如何?
      

  5.   

    to  fwjingling(蓝精灵):
    圣诞快乐!感谢回复!
    ____________________________________
    问题如上了!帮忙瞧瞧!
      

  6.   

    if cdsTemp.FieldByName('shrq').Value <> '' then
       begin
          ……
       end;
      

  7.   

    TField有很多类型转换方法,如AsString,AsInteger,AsDateTime...,可参照帮助正确进行类型转换。
      

  8.   

    to cyli888(学这东西真他妈的迷茫) :
    圣诞快乐!感谢回复!
    ____________________________________
    上面说的问题就是因他而起!
      

  9.   

    if cdsTemp.FieldByName('shrq').Value <> Null then
       begin
          ……
       end;
    提示Undeclared identifier:'null',是因为use unit中没有添加定义null的单元,delphi5.0中在system.pas中(好象会自动添加),好象记得DELPHI6.0有些变量定义的单元有变化,你可以点到单词上,然后按‘F1’看帮助null被定义在哪个单元,然后添加在use unit中。