none
Update datetime in tableAdapter RRS feed

  • Question

  • Hi,

    I have a form with some textboxes linked with a table adapter.

    Create, update and delete works fine when a use the TableAdapter.update(...)

    I only have problem with one textbox which is linked to a date.

    When I put a correct date in the textbox, my database is updated correctly

    When I erase the textbox, nothing is updated, the old date is still in the database !!

    In my database and dataset, null values are allowed...

    I don't understand..

    Monday, October 6, 2014 2:17 PM

Answers

  • Hello Fred and thanks for you reply...

    Actually, I had made the property "Auto-validate" of my form to "disable".

    So when my input was not a date (including empty string), it was not validated and no change was made by my update command...

    So i changed my "auto-validate" form property to "inherits" and add the following code :

    Private Sub DaTeValidation(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TbDtCreat.Validating
            If sender.text = "" Then
                sender.DataBindings("Text").DataSourceNullValue = DBNull.Value
                sender.DataBindings("Text").NullValue = ""
            End If

    End Sub

    And that's OK know...

    Bets regards.

    • Marked as answer by Pascal Le Goff Tuesday, October 7, 2014 12:14 PM
    Tuesday, October 7, 2014 12:11 PM

All replies

  • Hello Plug_Off,

    With your current description, I made a similar test, however, I cannot reproduce this issue you describes, I do know how you write your code. If it is possible, could you please upload a demo to the SkyDrive?

    >> When I erase the textbox, nothing is updated, the old date is still in the database !!

    If you are using sql server database, please have a try to use the SQL Server Profiler to check the database log to see if there is an error occurs during the execution.

    Best Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 7, 2014 2:25 AM
    Moderator
  • Hello Fred and thanks for you reply...

    Actually, I had made the property "Auto-validate" of my form to "disable".

    So when my input was not a date (including empty string), it was not validated and no change was made by my update command...

    So i changed my "auto-validate" form property to "inherits" and add the following code :

    Private Sub DaTeValidation(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TbDtCreat.Validating
            If sender.text = "" Then
                sender.DataBindings("Text").DataSourceNullValue = DBNull.Value
                sender.DataBindings("Text").NullValue = ""
            End If

    End Sub

    And that's OK know...

    Bets regards.

    • Marked as answer by Pascal Le Goff Tuesday, October 7, 2014 12:14 PM
    Tuesday, October 7, 2014 12:11 PM