为什么 TableAdapter 会用“1/1/2000”填充 DataSet?对于整个时间戳列?
我有一个 TableAdapter
填充 DataSet
,并且出于某种原因,每个选择查询都会使用值 1/1/2000 填充我的时间戳列。选定的行。
我首先验证了数据库端的原始值完好无损;大多数都是这样,尽管有几行由于在发现问题之前以编程方式执行的更新查询而丢失了其原始值。
DataColumn.DataType
是 DateType
,而 PgSQL 数据库列类型是 timestamp
。我最近注意到绑定的 DataGridView 控件中的问题,并通过使用 Visual Studio 数据集编辑器中的“预览数据”选项确认这与我的数据绑定无关。
检查属性和类型,甚至从头开始重新创建 TableAdapter
后,我感到非常困惑。我可以做什么来解决问题和/或诊断原因?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
框架(例如
DataTable
属性)不知道表字段的源类型;只有一个 DataType 属性来指示它期望能够将字段值转换成什么。该框架需要将日期类型转换为
DateTime
,因此需要在查询中转换时间戳值(例如SELECT timestamp::date FROM table),否则转换将失败,值为 1/1/2000。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.