fireBand fireBand - 2 years ago 69
MySQL Question

How To assign null values in MySql using VB.NET

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.

Dan Dan
Answer Source

AppDate = Nothing should work, you could also use DateTime.MinValue and update your business logic to treat it appropriately.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download