Tuesday, March 27, 2012

Adding a new column is DBNULL

Hello,

VS 2005

I am developing the database application. This is a live database and is being used by the customer. I am to release a new version and I had to add new columns to fit the requirements DateStarted (DateTime), and TotalHours(Int) into a database table.There are already over a 1000 rows in this table.

When the customer wants to look at a record in this table and insert the value into the text boxes (Front-end), when it gets to the DateStarted or TotalHours it comes up with a error message:"

The value for column 'DateStarted' in table 'IncidentTask' is DBNull."The method for inserting is:

Code Snippet

Me.dtDateStarted.Value = Me.DsIncidentsControl.IncidentTask(0).DateStarted

What are the possible solutions to this problem? Would it mean checking for a DBNULL before displaying in the textboxes? Or updating the new column rows with an date:

Code Snippet

UPDATE IncidentTask SET DateStarted = '1/1/2005' WHERE (DateStarted IS NULL)

Many thanks for any suggestions,

Steve

You can either have the application check for null values and display an empty string when dbnull,

OR,

UPDATE the table and put a 'dummy' date in all null rows.

No comments:

Post a Comment