- SQL code
use test5SELECT * INTO XLImport5 FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=z:\ownership_Platform_FI.xlsx;HDR=YES', 'SELECT * FROM [Sheet1$]')Msg 7308, Level 16, State 1, Line 2OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.
w 我估计可能是版本问题,求指教,
------解决方案--------------------
这个问题我不知道为什么。
我说说我的一点想法:Microsoft.Jet.OLEDB.4.0这个可以到数据源看看有没有这个驱动程序。
另外,如果想直接把数据库的某张表导入到EXCEL,可以直接复制。呵呵。
------解决方案--------------------
First, set the connection:
- C# code
private string ExcelConnection(){ return @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data Source=" + _strExcelFilename + ";" + @"Extended Properties=" + Convert.ToChar(34).ToString() + @"Excel 8.0;"+ ExcelConnectionOptions() + Convert.ToChar(34).ToString(); }#endregion
------解决方案--------------------
Excel2010应该使用Microsoft.ACE.OLEDB.12.0驱动了