求一MSSQL2008连接Excel2010的sql语句
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.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驱动了