如果传入 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.