问题:当日期为空时,有关如何将空值传递到存储过程的任何想法?
步骤1
Public modifieddate As Nullable(Of DateTime)
Run Code Online (Sandbox Code Playgroud)
第2步
If IsDBNull(dr("modifieddate")) = False Then
modifieddate = DateTime.Parse(dr("modifieddate"))
Else
modifieddate = Nothing
End If
Run Code Online (Sandbox Code Playgroud)
第3步
command.Parameters.Add("@modifieddate", SqlDbType.DateTime).Value = modifieddate
command.ExecuteNonQuery()
Run Code Online (Sandbox Code Playgroud)
如果没什么,我认为你必须通过DBNull.Value.像这样的东西:
If modifieddate Is Nothing then
command.Parameters.Add(...).Value = DBNull.Value
Else
command.Parameters.Add(...).Value = modifieddate
End If
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9765 次 |
| 最近记录: |