Results 1 to 5 of 5

Thread: Datepicker editing in WPF datagrid with MSAccess .mdb database

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    117

    Datepicker editing in WPF datagrid with MSAccess .mdb database

    Dear Guys,

    I have been developing a wpf application with a MS Access .mdb database. The pain window includes a range of textboxes from large data table, with 3 child tables to the main table, all as datagrids on the main window. I have had difficulties with the textboxes accepting null values, and this has been resolved for text formats by specifying acceptance of null values within the Access database. However, Access only allows this setting for text fields, not date fields.

    When I try to enter date values or changes in date fields (currently all datepickers), I cannot update the field using update functions, with a null exception thrown. I can work around this by placing the field in edit mode by double clocking or F2, and then exiting by tab once the data are added. However, this is clumsy. Does anyone have any thoughts on how this might be done more elegantly. eg is there code to emulate F2? I cant find it anywhere?

    Thanks again.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: Datepicker editing in WPF datagrid with MSAccess .mdb database

    Quote Originally Posted by Bear89 View Post
    Access only allows this setting for text fields, not date fields.
    That's simply not true. I'm not aware of any database that doesn't allow nulls in all columns regardless of data type, including Access. I just tested by creating a new Access database and added a Date/Time column to the default table and, sure enough, in design view I was able to specify Yes or No for Required. Not required, which was the default, means nullable.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    117

    Re: Datepicker editing in WPF datagrid with MSAccess .mdb database

    OK thanks jm, I have checked the parent Access setting and it is set to No for the Date:Required field.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: Datepicker editing in WPF datagrid with MSAccess .mdb database

    That means that saving NULL values to the database is not the issue, so you need to determine what is. Looking closely at the exception and its stack trace would be the place to start with that.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    117

    Re: Datepicker editing in WPF datagrid with MSAccess .mdb database

    Thanks Jm, at the moment no exception is being thrown, and I have tried a number of options but nothing is thrown. But the data of the row in question are simply not updated to the database when a change to the datepicker field is made. Does the fact that it can be resolved by F2-tab throw any light?

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