【发布时间】:2015-04-03 06:40:56
【问题描述】:
如果传递给 SqlBulkCopy.WriteToServer() 的 DataTable 包含无法转换的值,我会收到一个 InvalidOperationException ,显示无法转换的值。据我所知,列名不会显示在异常中的任何地方。发生这种情况时,我正在尝试记录列名和值。有没有办法检索这些信息?
System.InvalidOperationException: The given value of type SqlDecimal from the
data source cannot be converted to type decimal of the specified target column.
---> System.InvalidOperationException: The given value of type SqlDecimal from
the data source cannot be converted to type decimal of the specified target column.
---> System.ArgumentException: Parameter value '9999999999999999999999999999.00'
is out of range.
【问题讨论】:
-
我遇到了类似的问题,尽管挖得相当深也找不到答案,所以我也很想知道答案。
-
这可能有用csvreader.com/posts/validating_datareader.php。关于这个问题,它指出“使用 SqlBulkCopy 最令人沮丧的是缺乏有用的错误消息”......是的......
标签: .net vb.net exception sqlbulkcopy