ASP.Net SqlBulkCopy一些文本数据类型值转换为指数值

发布于 2024-12-17 08:21:23 字数 452 浏览 1 评论 0原文

ASP.Net SqlBulkCopy 将一些文本数据类型值转换为指数值,

bulkCopy.DestinationTableName = "TABLE NAME";
bulkCopy.ColumnMappings.Add("Mobilenumber", "Mobilenumber");
bulkCopy.WriteToServer(dr);

上面的代码将文本数据类型的 Excel 列 mobilenumbers 插入数据库列 mobilenumber varchar(100)

有些数字插入时没有任何更改,但有些数字作为指数值插入。

如果 Excel 列的数据类型更改为 Number,前导零为 0,则无需转换为指数,值将插入到数据库表中。

我的要求是无需手动转换任何工作表数据类型(仅限工作表),我必须上传,因为我必须上传许多文件。 请问有人可以帮忙解决这个问题吗?

ASP.Net SqlBulkCopy some text data type values converting to exponential values

bulkCopy.DestinationTableName = "TABLE NAME";
bulkCopy.ColumnMappings.Add("Mobilenumber", "Mobilenumber");
bulkCopy.WriteToServer(dr);

above code inserting excel column mobilenumbers of text data type to database column mobilenumber varchar(100)

Some numbers are inserting without any change but some numbers inserting as exponential values.

If datatype of excel column changed to Number with leading zeroes is 0 then without converting into exponential , values are inserting into database table.

My requirement is without converting any sheet datatype (To the sheet only) manually, i have to upload because i have to upload many files.
Please, can any one help on this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

删除→记忆 2024-12-24 08:21:23

通过使用以下连接字符串并更改 Jet 和 ACE 注册表中 TypeGuessRows=0 的设置。

ExelconnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filname + ";Extended Properties=\"Excel 8.0;IMEX=1;ImportMixedTypes=Text;TypeGuessRows=0;\"";


ExelconnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filname + ";Extended Properties='Excel 12.0;IMEX=1;ImportMixedTypes=Text;TypeGuessRows=0';"; 

By using the below connection strings and changing the setting for TypeGuessRows=0 in the registry of Jet and ACE.

ExelconnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filname + ";Extended Properties=\"Excel 8.0;IMEX=1;ImportMixedTypes=Text;TypeGuessRows=0;\"";


ExelconnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filname + ";Extended Properties='Excel 12.0;IMEX=1;ImportMixedTypes=Text;TypeGuessRows=0';"; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文