#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11

    Unhappy Converting a DateTimePicker value in null ?


    I am coding in Vb.Net
    I knew it was possible (or I am pretty sure it was) in vb.6 to use the null in a datetimepicker.

    I need to have 2 dateTimePicker cause at first it was only textbox that were validated, but I got a request from some users that they wanted to see a Calender at this place.

    I have one that is the Date I received the documents and the other one is the date the document has been send back.

    for the first one, I don't have problem, there is always a value in it, today or another one.

    but for the second one. if the documents haven't been send back yet, the value need to be Nothing, it's need to be empty. but I haven't found any way to do it.

    when I do, DateTimePicker1.Value = System.DBNull.Value
    it's just tell me that a DbNull.Value can't be converted to a date value.

    What's should I do then ?
    my boss told me that January 1 of 1900 is a null value but that's not true, I haven,t found anything about it. and that way it will be complicate for the user to delete de date, he won't remeber to change it for january 1, 1900


    Any one got any idea on how I could go and get all of this out and running ?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    USA
    Posts
    313
    Rep Power
    18
    Are you putting this in a database and have to make the field NULL.

    PHP Code:
    Private Sub btnClear1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles btnClear1.Click
            
    'This Clears the Media Date and sets it to DBNULL
            '
    MessageBox.Show(Me.dsMediaInfo.Tables("MediaInfo").Rows(0).Item(4))

            
    Me.dsPhotoInfo.Tables("PhotoInfo").Rows(0).Item(3) = System.DBNull.Value

        End Sub 
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    No, what I wanted to do is the inverse. I want the datetimepicker to be at null if it's need to.

    It's read the information from the database and add the date to the datetimepicker but sometimes the date in the database is null, soo I need to add a Null Value to the datetimepicker.

    and the user also need to have the possibility to choose a null value for the date to record it in the database.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    USA
    Posts
    313
    Rep Power
    18
    what you could do is this have a default value if it is null. Like January 1 of 1900 so when you save the record back to the database use the datepicker validation if equal to January 1 of 1900 then set the value for that field in the database to System.DBNull.Value. I have had similiar issues with the datepicker control. It is great to use but has some issue that is to bad.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    Originally posted by iamtgo3
    what you could do is this have a default value if it is null. Like January 1 of 1900 so when you save the record back to the database use the datepicker validation if equal to January 1 of 1900 then set the value for that field in the database to System.DBNull.Value. I have had similiar issues with the datepicker control. It is great to use but has some issue that is to bad.
    yeah that's the samething I was thinking of doing. But it could complicate some people. You would need to go choose that date everytime the user want a date :S ! that's bad imo.

    also, because the users check the textbox and if it's empty it,s mean that the document haven't been sent, if there is a value, that's mean it's haven been sent. soo with a date in a datapicker with will be more complicate may be for them

    I don't know what to do lol

IMN logo majestic logo threadwatch logo seochat tools logo