我在If
之前正在运行INSERT
语句,以比较是否输入了日期。如果输入了一个值,我将此值赋给变量(用作参数值),但如果没有输入任何值,我需要输入任何内容,以便在加载数据时,格式仍然是__ / __ / __
但是,使用datevar = Nothing
插入时,它会将其插入01/01/2001。我也尝试过使用DBNull.Value,但这一直在说DBNull.Value cannot be converted to type 'Date'
如何让查询插入空/ null以便返回__ / __ / __?
Dim delDate As Date
If dr.Item("Goods_Delivered") = False Then
delivVal = 0
delivVol = 0
sino = ""
delDate = DBNull.Value
Else
Try
delivVal = dr.Item("deliveryVal")
delivVol = dr.Item("deliveryVol")
sino = dr.Item("Supplier_Invoice_Number")
delDate = dr.Item("Final_Delivery")
Catch ex As Exception
delivVal = 0
delivVol = 0
sino = 0
End Try
End If
答案 0 :(得分:0)
将delDate初始化为DateTime.MinValue
Dim delDate as Date = #1/1/0001 12:00:00 AM#
然后在构造insert语句时,检查delDate = DateTime.MinValue。如果是,请插入NULL。否则插入delDate。