在数据类型中存在冲突的SqlBulk副本 [英] SqlBulk copy filed with conflict in datatypes

查看:71
本文介绍了在数据类型中存在冲突的SqlBulk副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我想使用SQLBulkcopy将制表符分隔文本文件中的一些批量数据转储到数据库表。



这里我的问题是我的数据库表有数据类型为nvarchar的列,而我的数据表使用columns数据类型定义为String,它抛出异常如下:

  String   value 来自数据源无法转换为指定目标列的类型nvarchar。





请建议我如何将列数据类型定义为nvarchar而不是数据表的字符串。

 dtData.Columns.Add(  RegionCode typeof  string )); 





或者请建议我任何替代方案。



谢谢..

解决方案

c#无法使用sqlbulkcopy插入数据表 [ ^ ]。

Quote:

这可能是由于列太短而引起的。如果您的ShortText列定义为NVARCHAR(30)并且您有一个40个字符的字符串,则可能会出现该错误。请参阅此处:

http://forums.asp.net/p/1228890 /2212376.aspx [ ^ ]


Hi Friends,

I want to dump some bulk data from tab delimited text file to database table using SQLBulkcopy.

Here my issue is my database tables are having columns with datatype as nvarchar whereas my datatable defined with columns datatype as String which throws an exception as follows:

The given value of type String from the data source cannot be converted to type nvarchar of the specified target column.



Please suggest me how to define a column datatype as nvarchar rather than string for a datatable.

dtData.Columns.Add("RegionCode", typeof(string));



or please suggest me any alternative.

Thank You..

解决方案

c# can''t insert data table using sqlbulkcopy[^].

Quote:

It may be caused by a too-short-column. If your ShortText column is defined as NVARCHAR(30) and you have a 40 character string, you may get that error. See here for example:
http://forums.asp.net/p/1228890/2212376.aspx[^]


这篇关于在数据类型中存在冲突的SqlBulk副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆