使用 SqlDataAdapter 插入时保留换行符
作为我正在开发的 (C#) Windows 服务的一部分,我正在提取 CSV 的内容并将它们转储到 DataTable 中单行的单个字段中。我使用 DataTable 是因为有时我可能需要添加多个 CSV。
问题是,SqlDataAdapter 插入正在删除换行符并将其转换为空格。
那么有人知道是否可以保留换行符吗?或者我是否必须用其他一些标记替换换行符,然后我可以稍后将其转换回换行符?
干杯
As part of a (C#) windows service I'm working on I'm pulling the contents of a CSV and dumping them into a single field on a single row in a DataTable. I'm using a DataTable because at times I may have more than one CSV to add.
The problem is, the SqlDataAdapter insert is removing the line-breaks and converting these into spaces.
So does anyone have any idea if it's possible to preserve line-breaks? Or am I just going to have to go with replacing the line-breaks with some other marker that I can then convert back into line-breaks later?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来这是我的一个误会。 sql server 输出似乎没有换行符,但它们毕竟被保留了。希望这可以帮助那些像我一样经历过麻木时刻的人。
Looks like it was a misunderstanding on my part. The sql server output appeared to have no line-breaks but they were being preserved after all. Hope this helps someone else who's having a numpty moment like I was.