Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 554
fireBand Avatar asked Mar 05 '10 22:03

fireBand


2 Answers

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

like image 103
Dan Avatar answered Sep 29 '22 10:09

Dan


AppDate = Nothing

like image 20
IniTech Avatar answered Sep 29 '22 10:09

IniTech