Private m_ExpirationDate As Nullable(Of DateTime)
Public Property ExpirationDate() As Nullable(Of DateTime)
Get
Return m_ExpirationDate
End Get
Set(ByVal value As Nullable(Of DateTime))
m_ExpirationDate = value
End Set
End Property
Dim rec As New DBML.Staff With _
{.StaffDesc = m_StaffDesc, _
.LastName = m_LastName, _
.FirstName = m_FirstName, _
.MiddleInit = m_MiddleInit, _
.Gender = m_Gender, _
.Certification = m_Certification, _
.ExpirationDate = m_ExpirationDate, _ ********
.Active = m_Active, _
.CEPDNo = m_CEPDNo, _
.FaNo = m_FaNo, _
.PIC = m_PIC, _
.PICValid = m_PICValid, _
.PICCheckDate = Today(), _
.PICError = m_PICError}
_db.Staffs.InsertOnSubmit(rec)
Try
_db.SubmitChanges()
RetVal = rec.StaffID.ToString
Catch exp As Exception
RetVal = "Insert Failed:" & exp.Message
End Try
当我运行 insertonsubmit 时,它会失败,因为 m_ExpirationDate 的值为 null,尽管它显示 12:00:00:00AM。那么我该如何测试这个值,如果它为空,请不要将它包含在“InsertOnSubmit”语句中。我不想传递像 1/1/1900 这样的虚假值。
任何帮助表示赞赏。