【问题标题】:bulk copy throws an exception when there is a DateTime column有 DateTime 列时,大容量复制会引发异常
【发布时间】:2013-04-04 11:36:49
【问题描述】:

我正在 c# 中进行批量复制,它工作正常,除非我将 DateTime 列添加到 DataTable 中,当我删除 DateTime 列并执行批量复制时,批量复制会引发 The given ColumnMapping does not match up with any column in the source or destination. 异常正常

添加 DateTime 列时我需要做些什么吗?

【问题讨论】:

  • DateTime.MinValue\MaxValue 不适合 SQL DateTime。确保不插入此值。使用可为空的日期时间?在 C# 代码中指定无日期值。
  • 您确定区分大小写吗?检查数据库和数据表之间的列名
  • 您确定目标表中的日期\时间列可用吗?

标签: c# sql sql-server-2008-r2 columnmappings


【解决方案1】:

根据我的经验,以下是导致此类问题的可能性

  1. 源和表中的列名匹配 列类型匹配

  2. 在你的表的日期\时间列中允许空值,然后通过DataTable插入空值,如果它有效,那么数据映射的问题就是问题。

【讨论】:

    【解决方案2】:

    这可能不是因为它是 DateTime 列 - 请检查您的 ColumnMapping 名称,因为它们区分大小写 - 这可能是问题所在。

    博客here

    【讨论】:

    • 正如我所说,只要从映射中删除 DateTime 列,一切都会起作用
    • 但它会将该列复制到目标表中吗...?
    猜你喜欢
    • 2020-03-18
    • 1970-01-01
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多