views:

92

answers:

1

I have a TableAdapter filling a DataSet, and for some reason every select query populates my timestamp column with the value 1/1/2000 for every selected row.

I first verified that original values are intact on the DB side; for the most part, they are, although it seems a few rows lost their original timestamp because of update queries performed programmatically before the issue was discovered.

The DataColumn type is DateType, while the database (Postgres) column type is timestamp. Up until recently, this was all playing very nicely. I noticed the issue in a bound DataGridView control, and verified that this is not related to data binding by utilizing the 'Preview Data' option in the VS DataSet Editor.

Usually when I notice unexpected values popping up in my application it's related to a mis-configured property, type conflict, or another silly mistake I've made. So after checking properties and types, and even recreating the TableAdapter from scratch, to say I'm a little baffled is an understatement.

Does anyone have any ideas of what I could do to fix the issue and/or diagnose the cause?

A: 

The framework (eg. DataTable properties) doesn't know the source type of a table field; there's simply a DataType property that indicates what it expects to be able to convert the field value into.

The framework expects a date type for converting to DateTime, so timestamp values need to be converted in the query (ex. SELECT timestamp::date FROM table) or the conversion will fail, giving a value of 1/1/2000.

Rob