<bdo id='iSJfP'></bdo><ul id='iSJfP'></ul>

  • <small id='iSJfP'></small><noframes id='iSJfP'>

    <tfoot id='iSJfP'></tfoot>
    <i id='iSJfP'><tr id='iSJfP'><dt id='iSJfP'><q id='iSJfP'><span id='iSJfP'><b id='iSJfP'><form id='iSJfP'><ins id='iSJfP'></ins><ul id='iSJfP'></ul><sub id='iSJfP'></sub></form><legend id='iSJfP'></legend><bdo id='iSJfP'><pre id='iSJfP'><center id='iSJfP'></center></pre></bdo></b><th id='iSJfP'></th></span></q></dt></tr></i><div id='iSJfP'><tfoot id='iSJfP'></tfoot><dl id='iSJfP'><fieldset id='iSJfP'></fieldset></dl></div>

      1. <legend id='iSJfP'><style id='iSJfP'><dir id='iSJfP'><q id='iSJfP'></q></dir></style></legend>
      2. IBM Data Server Client v9.7fp5 的日期时间字段溢出

        Datetime field overflow with IBM Data Server Client v9.7fp5(IBM Data Server Client v9.7fp5 的日期时间字段溢出)
        <legend id='J1o8n'><style id='J1o8n'><dir id='J1o8n'><q id='J1o8n'></q></dir></style></legend>

          <bdo id='J1o8n'></bdo><ul id='J1o8n'></ul>
        • <small id='J1o8n'></small><noframes id='J1o8n'>

            <tfoot id='J1o8n'></tfoot>
              <tbody id='J1o8n'></tbody>
          • <i id='J1o8n'><tr id='J1o8n'><dt id='J1o8n'><q id='J1o8n'><span id='J1o8n'><b id='J1o8n'><form id='J1o8n'><ins id='J1o8n'></ins><ul id='J1o8n'></ul><sub id='J1o8n'></sub></form><legend id='J1o8n'></legend><bdo id='J1o8n'><pre id='J1o8n'><center id='J1o8n'></center></pre></bdo></b><th id='J1o8n'></th></span></q></dt></tr></i><div id='J1o8n'><tfoot id='J1o8n'></tfoot><dl id='J1o8n'><fieldset id='J1o8n'></fieldset></dl></div>

                  本文介绍了IBM Data Server Client v9.7fp5 的日期时间字段溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 EntityFramework v4.1 和 IBM Data Server Client v9.7fp5,DB 首先基于具有 DATE 列的预定义 DB2 表生成代码.DB2 DATE 列在代码生成期间映射到 .NET DateTime 数据类型.

                  Using EntityFramework v4.1 and IBM Data Server Client v9.7fp5, DB first generated code based on a pre-defined DB2 table which has DATE columns. The DB2 DATE columns are mapped to .NET DateTime data types during the code generation.

                  尝试INSERT一行时,收到以下错误

                  When attempting to INSERT a row, receive the following error

                  ERROR [22008] [IBM] CLI0114E 日期时间字段溢出.SQLSTATE=22008

                  ERROR [22008] [IBM] CLI0114E Datetime field overflow. SQLSTATE=22008

                  这是有道理的,因为 .NET 没有 DATE 数据类型,只有 DATETIME 并且该属性将包含比 DB2 DATE 列所期望的更多的数据.

                  which makes sense, since .NET does not have a DATE data type, just DATETIME and that attribute would have more data then the DB2 DATE column would expect.

                  问题是

                  1. 为什么 .NET 基本代码不使用 ToShortDateString() 自动转换并为 DB2 提供它所期望的?

                  1. why doesn't the .NET base code automatically convert using ToShortDateString() and provide DB2 what it is expecting?

                  在 .NET 将 SQL 事务提交给 DB2 之前,可以使用哪些方法来覆盖 .NET 基本逻辑并转换应用程序代码中的值?

                  what approaches could be used to override the .NET base logic and convert the value within application code before .NET submits the SQL transaction to DB2?

                  我们将不胜感激任何帮助或反馈.谢谢!

                  Any assistance or feedback would be appreciated. Thanks!

                  推荐答案

                  阅读datetime 数据类型转换 (ODBC).它在数据类型转换中定义了各种规则.下面列出了一个 - SQLSTATE 22008.

                  Read datetime Data Type Conversions (ODBC). It defines various rules in datatype conversions. One is listed below - SQLSTATE 22008.

                  如果在从 C 转换到 SQL 时发生秒数或小数秒的截断,则会生成带有 SQLSTATE 22008 的诊断记录和消息日期时间字段溢出".

                  If truncation of seconds or fractional seconds occurs when converting from C to SQL, a diagnostic record is generated with SQLSTATE 22008 and the message "Datetime field overflow".

                  这里的关键是确保在秒/小数秒内没有发生truncation

                  The key point here is to make sure that there happens no truncation in seconds/fractional seconds

                  日期数据类型

                  如果 DB2 数据库列是 DATE 数据类型,请创建如下所列的变量:

                  If the DB2 database column is DATE datatype, create your variable as listed below:

                  new DateTime(2012,3,4); //No time part
                  

                  TIMESTAMP 数据类型

                  如果 DB2 数据库列是 TIMESTAMP 数据类型,则删除毫秒的小数部分:

                  If the DB2 database column is TIMESTAMP datatype, remove fraction of milliseconds:

                  dateTime = new DateTime(dateTime.Ticks - (dateTime.Ticks % TimeSpan.TicksPerSecond),dateTime.Kind);
                  

                  参考:

                  1. 如何截断 .NET DateTime 的毫秒数
                  2. 为什么 SQL Server 会丢失一毫秒?

                  <小时>

                  DATE 和 TIMESTAMP 的 DB2 INSERT

                  如果您在 DB2 中使用直接 SQL 语句插入,

                  If you inserting with direct SQL statement in DB2,

                  对于时间戳使用格式,如2012-12-17-16.53.57.285754"

                  for TimeStamp use format like '2012-12-17-16.53.57.285754'

                  对于 DATE,使用格式如 CAST ('2012-12-10' AS DATE)

                  for DATE use format like CAST ('2012-12-10' AS DATE)

                  这篇关于IBM Data Server Client v9.7fp5 的日期时间字段溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  IBM.Data.DB2.Core connection problems(IBM.Data.DB2.Core 连接问题)
                  Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  SQL0666 - SQL query exceeds specified time limit or storage limit(SQL0666 - SQL 查询超出指定的时间限制或存储限制)
                  Cannot connect to DB2: IBM.Data.DB2.Core version 3.1.0.400 on Azure Function(无法连接到 DB2:Azure 函数上的 IBM.Data.DB2.Core 版本 3.1.0.400)
                    <tbody id='6ZwWE'></tbody>
                    • <i id='6ZwWE'><tr id='6ZwWE'><dt id='6ZwWE'><q id='6ZwWE'><span id='6ZwWE'><b id='6ZwWE'><form id='6ZwWE'><ins id='6ZwWE'></ins><ul id='6ZwWE'></ul><sub id='6ZwWE'></sub></form><legend id='6ZwWE'></legend><bdo id='6ZwWE'><pre id='6ZwWE'><center id='6ZwWE'></center></pre></bdo></b><th id='6ZwWE'></th></span></q></dt></tr></i><div id='6ZwWE'><tfoot id='6ZwWE'></tfoot><dl id='6ZwWE'><fieldset id='6ZwWE'></fieldset></dl></div>
                        <legend id='6ZwWE'><style id='6ZwWE'><dir id='6ZwWE'><q id='6ZwWE'></q></dir></style></legend>

                        <small id='6ZwWE'></small><noframes id='6ZwWE'>

                      1. <tfoot id='6ZwWE'></tfoot>
                          <bdo id='6ZwWE'></bdo><ul id='6ZwWE'></ul>