I am not sure why VB makes everything such a pain. I have a fields which stores the date and time in the format required to store in MySQL database
Dim AppDate As String = String.Empty
If Not String.IsNullOrEmpty(Me.AppDate.Text.Trim) Then
AppDate = Format(CDate(Me.AppDate.Text), "yyyy-MM-dd h:mm:ss")
Else
//Need to assign a null value to AppDate
End If
Now I need to assign the AppDate to NUll like DBNull, but I am not able to do it directly. If I change AppDate to Date then I am not getting the required format.
Any help is appreciated .
Thanks in Advance.
AppDate = Nothing should work, you could also use DateTime.MinValue and update your business logic to treat it appropriately.
AppDate = Nothing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With