Question

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 in the database side; most are, though a few rows lost their original value because of update queries performed programmatically before the issue was discovered.

The DataColumn.DataType is DateType, while the PgSQL database column type is timestamp. I recently noticed the issue in a bound DataGridView control, and confirmed this is not related to my data-binding by using the Preview Data option in the Visual Studio DataSet Editor.

After checking properties and types, and even recreating the TableAdapter from scratch, I'm pretty baffled. What I can do to fix the issue and/or diagnose the cause?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top