我是用DELPHI+ADO+SQL,现在我的数据库中有一个时段表,如下:
punchin1 punchout1 punchin2 punchout2
07:30 12:30 14:00 18:00
07:30 18:00 null null
现在我在DELPHI界面中,用EDIT的控件显示时间段,同样要追加一个记录,也根据EDIT控件的值,现在我的EDIT控件值为空,怎么样才能正确的追加到时段表中表示为空的呢?我用EDIT1.TEXT=:NULL,提示转换错误,正确的方法是怎样的呢?
punchin1 punchout1 punchin2 punchout2
07:30 12:30 14:00 18:00
07:30 18:00 null null
现在我在DELPHI界面中,用EDIT的控件显示时间段,同样要追加一个记录,也根据EDIT控件的值,现在我的EDIT控件值为空,怎么样才能正确的追加到时段表中表示为空的呢?我用EDIT1.TEXT=:NULL,提示转换错误,正确的方法是怎样的呢?
if Components[i] if TEdit then //如果控件为Edit
if TEdit(Components[i]).Text = '' then //如果Edit的Text为''
TEdit(Components[i]).Text := Null; //则赋值为Null
Var
sj:TDateTime;
begin
if Edit1.text='' then
begin
sj:=null;(....................)
end
else
sj:=StrToDateTime(Edit1.text);
end;
编译程序没有任何问题,但是我在单步测试时,运行到此处时,程序报错误:'Could not convert variant of type(null) into type(double);这是为什么呀