Default 'GetDate()' values and DTP 'ShowCheckBox'

  • Struggling with Dates using databbinding and dataset wizards.

    Have set a database field 'DateOfMarriage = DateTime, Length = 8, AllowNulls = Yes, Unique = No, PrimaryKey = No'. Have set Default Value as GETDATE().

    When I enter date through Show Table Data is permits Null Values. When I view data through the default dataset for the table into the DateTimePicker control it is picking up a date from a previous entry.

    Ideally, I would like to use the 'ShowCheckBox' for this control so that if Not Checked it defaults to Null status and if Checked shows actual date entered.

  • If you will try to enter the NULL value into the column with the definition AllowNull = Yes, it will permit the NULL value to be inserted even if you have the default value set for the column.

    Default value will be used by the column only if there is no value supplied at all within insert statement.

    Also, why you want to have the column which allows NULL and also have the default value set for it?

    Prashant Bhatt
    Sr Engineer - Application Programming

  • Thank you for your response. I will remove the default GetDate() and see what happens.

    Have removed GetDate() and updated dataset etc. No change. Currently I have six records for testing in the table. Record #1 is Null and displays current date. Record #2 has date of 10/10/1963. Record #3 is Null but displays Record #2's date. Record #4 is also Null and displays record #2's date. Record #5 has date of 06/06/1997. Record #6 is Null but displays Record #5's date.

    Data is being selected via a combobox. It appears to me that a refresh is somehow required when moving through the records, or, do I have to set any options in the advanced databinding of the date field.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply