无法使用c#将excel文件导出到sql server [英] cannot able to export excel file to sql server using c#
本文介绍了无法使用c#将excel文件导出到sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友
我已经在谷歌尝试了我的小时和小时问题。但我无法解决我的问题。
优先:
我用的是
1)windows 8(64位)2)visual studio 2010 (X86)3)sql server 2008(64位)4)Ms office(32位)。
我安装了Accessdatabaseengine(32位),因为我无法安装64位。
我的错误是
hi friends
I have tried in google for my problem with hour and hour. but i am not able to solve my problem.
first:
I am using
1)windows 8(64 bit) 2)visual studio 2010 (X86) 3) sql server 2008 (64 bit) 4)Ms office (32 bit).
I installed Accessdatabaseengine (32 bit) because i cannot able to install 64 bit.
My Error is
OLE DB provider 'Microsoft.ACE.OLEDB.12.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.
也我在sq服务器中更改以下内容
also i change the following in sq server
exec sp_configure 'show advanced options', 1
reconfigure
GO
exec sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
推荐答案
你必须确定规格/范围你的问题:
如果你想使用CSharp从Sql Server中的XL文件导入数据,那么:
你不需要MS Office
你不需要Accessdatabaseengine
你可能不应该使用OLE DB驱动程序而是使用本机sql server一个...
读取你的XL数据:
使用像(优秀的)ClosedXML [ ^ ]
一旦读取了数据,你就可以对你的sql server表进行非常经典的插入/更新
You must firm-up the specs/scope of your problem:
if you want to import data from XL files within Sql Server using CSharp then :
you don't need MS Office
you don't need Accessdatabaseengine
and you should probably not use the OLE DB driver but the native sql server one...
To read your XL data:
use a library like (the excellent) ClosedXML[^]
Once the data is read you soimply do very classic Insert/Updates to your sql server table(s)
这篇关于无法使用c#将excel文件导出到sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文