ADOQuery替换ADOtable出错,could not convert variant of type (null) into type (double)

  • 主题发起人 d_delphi
  • 开始时间
D

d_delphi

Unregistered / Unconfirmed
GUEST, unregistred user!
ADOQuery替换ADOtable出错,could not convert variant of type (null) into type (double).(3分)<br />select * from plan_tab where 完成时间>'''+formatdatetime('yyyy/mm/dd hh:mm:ss',DataModule4.ADOtable['计划完成时间'])+'''SQL语句运行正常,连接同样的表,用ADOQuery替换ADOtable(即select * from plan_tab where 完成时间>'''+formatdatetime('yyyy/mm/dd hh:mm:ss',DataModule4.ADOQuery['计划完成时间'])+'''SQL)时运行就会出现could not convert variant of type (null) into type (double).错误,何解?
 
help me......
 
注意換行,
你看看DataModule4.ADOQuery['计划完成时间'])的值是否為null,
即可能你用adoquery替換adotable時,可能因為條件變化,沒有找到
記錄,造成讀出來的是null值,所以轉換成日期型失敗。
 
楼上说的有道理,但问题应怎样解决呢?
 
加一句判断不就行了。
 
老大还是换换行先!
》select * from plan_tab
where 完成时间>'''+formatdatetime('yyyy/mm/dd hh:mm:ss',DataModule4.ADOtable['计划完成时间'])+'''SQL语句,
运行正常,连接同样的表,用ADOQuery替换ADOtable,

即select * from plan_tab
where 完成时间>'''+formatdatetime('yyyy/mm/dd hh:mm:ss',DataModule4.ADOQuery['计划完成时间'])+'''SQL)时,

运行就会出现could not convert variant of type (null) into type (double).错误,何解?
---------------------------
问题是在这来了吧: DataModule4.ADOQuery['计划完成时间'])
把你 DataModule4.ADOQuery的查询语句看一下吧,不让它找到空值!~
或者检查你的数据库数据是不是有问题!
 
if not DataModule4.ADOQuery.fieldbyname('计划完成时间').isnull then
begin
adoquery1.close;
adoquery1.sql.text:='select * from plan_tab where 完成时间>'''+formatdatetime('yyyy/mm/dd hh:mm:ss',DataModule4.ADOQuery['计划完成时间'])+'''';
adoquery1.open;
....
end
else
showmessage('沒有計算完成時間記錄');
 
if DataModule4.ADOtable['计划完成时间'] = null then Exit;
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
563
import
I
I
回复
0
查看
631
import
I
I
回复
0
查看
844
import
I
顶部