zoukankan      html  css  js  c++  java
  • 解决SQL Server 2008 64位系统无法导入Access/Excel的问题

    最近更换了新服务器,操作系统Windows Server 2008 X64,数据库SQL Server 2008 X64,Office 2007(好像只有32位),在存储过程执行OpenDatasource导入Access数据的时候遇到问题了,Oledb 4.0已经不被支持,以下是遇到的若干错误提示:
    
    因为 OLE DB 访问接口 'Microsoft.Jet.OLEDB.4.0' 配置为在单线程单元模式下运行,所以该访问接口无法用于分布式查询。
    无法创建链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.Ace.OLEDB.12.0" 的实例。
    因为 OLE DB 访问接口 'Microsoft.Ace.OLEDB.12.0' 配置为在单线程单元模式下运行,所以该访问接口无法用于分布式查询 。
    
    
    解决方案是安装Office 2010 64位版, 网上有很多下载,然后下载Microsoft Access Database Engine 2010 的X64版本,网上也有下载,两者缺一不可。
    
    然后改一下OpenDatasource参数,将 Microsoft.Jet.OLEDB.4.0 改为 Microsoft.ACE.OLEDB.12.0,大功告成。
    
    贴上存储过程部分代码:
    --开启导入功能
        exec sp_configure 'show advanced options',1
        reconfigure
        exec sp_configure 'Ad Hoc Distributed Queries',1
        reconfigure
        --允许在进程中使用ACE.OLEDB.12
        EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
        --允许动态参数
        EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
        
        --导入临时表 
        exec ('insert into jihua(id,[批次号],Right('''+ @filepath +''',charindex('''',REVERSE('''+ @filepath +'''))-1),getdate() FROM OPENDATASOURCE (''Microsoft.ACE.OLEDB.12.0'', ''Data Source='+@filepath+';User ID=Admin;Password='' )...计划汇总表')
    
        --注意这里,要先关闭外围的设置,然后再关闭高级选项
        exec sp_configure'Ad Hoc Distributed Queries',0
        reconfigure
        exec sp_configure'show advanced options',0
        reconfigure
        --关闭ACE.OLEDB.12的选项
        EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 0
        EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 0
  • 相关阅读:
    [轉]Flex实现代码分离mxml/as
    [轉]PHP执行MYSQL存储过程报错:Commands out of sync; you can't run this command now 问题的解决
    [轉]mysqli & pdo使用实例和详解
    JSON格式驗證以及格式說明
    [轉]can't return a result set in the given context及参数解释
    PHP ADODB資源
    [轉]Virtual PC 网络设置(Networking)
    [轉]20个非常有用的PHP类库
    [轉]MySQL存储过程 ERROR Handler 异常处理
    [轉]如何通过Jquery获取radio的值
  • 原文地址:https://www.cnblogs.com/sky6699/p/6050063.html
Copyright © 2011-2022 走看看