Results 1 to 3 of 3

Thread: [RESOLVED] Need Help: Insert null value

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    328

    Resolved [RESOLVED] Need Help: Insert null value

    I am using Vb6 and Mysql database

    I am having a problem on saving null value on date field.

    If it has a date it saves, and if doesn't have it also saves but when
    I tried to look at the database table instead of Null it become 0000-00-00.

    How do I set it as Null?

    Code:
    Dim sDateEnd As String
    
    If txtDates(1).Text <> "mm/dd/yyyy" Then
        sDateEnd = Format(txtDates(1).Text, "yyyy-MM-dd")
    Else
        sDateEnd = ""
    End If
    
    strUpdate = "INSERT INTO tbl_employees (tsk_end) VALUES (" _
    & "'" & IIf(IsNull(sDateEnd), Null, sDateEnd) & "'" _
    & ")" 
    
    conn.Execute strUpdate
    ANY Help?
    Last edited by morbid.ivan; Sep 12th, 2015 at 03:04 AM.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    328

    Re: Need Help: Insert null value

    Thank you for viewing... I solve it.

    Code:
    Dim sDateEnd As String
    
    If IsDate(txtDates(1).Text) Then
        sDateEnd = Format(txtDates(1).Text, "yyyy-MM-dd")
    Else
        sDateEnd = "NULL"
    End If
    
    strUpdate = "INSERT INTO tbl_employees (tsk_end) VALUES (" _
    & "date('" & sDateEnd & "') " _
    & ")" 
    
    conn.Execute strUpdate

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    328

    Re: [RESOLVED] Need Help: Insert null value

    and also this:
    Code:
    date(IfNull(Null,'" & Format(txtDates(1).Text, "yyyy-MM-dd") & "'))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width