加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何跳过不良记录

发布时间:2020-12-16 01:50:34 所属栏目:百科 来源:网络整理
导读:我正在使用 File Helpers 2.9.9 ,我想知道如何让它跳过不良记录而不是崩溃? object[] transactions = engine.ReadStream(textReader); // will crash if one record fails. 我也遇到了DateTime的问题.我无法理解为什么它无法使用我设置的格式转换为“12/22/
我正在使用 File Helpers 2.9.9 ,我想知道如何让它跳过不良记录而不是崩溃?

object[] transactions = engine.ReadStream(textReader); // will crash if one record fails.

我也遇到了DateTime的问题.我无法理解为什么它无法使用我设置的格式转换为“12/22/2011”.

Error Converting '"12/22/2011"' to type: 'DateTime'.  does not match any of the given formats: 'MM/dd/yyyy','MM/d/yyyy','M/d/yyyy'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: FileHelpers.ConvertException: Error Converting '"12/22/2011"' to type: 'DateTime'.  does not match any of the given formats: 'MM/dd/yyyy','M/d/yyyy'

解决方法

1)[编辑] – 我错了,你可以将engine.ErrorManager.ErrorMode设置为SaveAndContinue – 参见示例@ http://www.filehelpers.com/example_errorhandling.html

2)基于包含带双引号的字符串的单引号,我想问题是你需要提供FieldQuoted属性 – 参见http://www.filehelpers.com/attributes.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读