8
Answers

Getting error of 'Microsoft.ACE.OLEDB.12.0'

Hello folks,

 
 I am currently using SQL Server R2 in Windows 7 64 Bit OS.
 I want to update my existing database table  (WANT TO UPDATE ONLY ) from spreadsheet (Excel) workbook.
 
i am using MS Office 7. 
 
 
my Stored Procedure Looks like: 
-- ================================================

-- Template generated from Template Explorer using:

-- Create Procedure (New Menu).SQL

--

-- Use the Specify Values for Template Parameters

-- command (Ctrl-Shift-M) to fill in the parameter

-- values below.

--

-- This block of comments will not be included in

-- the definition of the procedure.

-- ================================================

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

---C:\foldername\spreadsheetname.xls

---C:\Users\Public\Documents\DemoUpdate.xlsx

-- =============================================

-- Author: KP Singh

-- Create date: 21/Nov/2014

-- Description: Update tbAddress anf tbSupplierMaster from Excel Spreadsheet

-- =============================================

CREATE PROCEDURE usp_undateSupplierandaddress

-- Add the parameters for the stored procedure here

--@filepath varchar(100)

AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from

-- interfering with SELECT statements.

SET NOCOUNT ON;

BEGIN TRANSACTION

UPDATE tbSupplierMaster

SET tbSupplierMaster.SupplierCode = ExcelTable.SupplierCode,

tbSupplierMaster.SupplierName = ExcelTable.SupplierName,

tbSupplierMaster.TinNo = ExcelTable.TinNo,

tbSupplierMaster.CST = ExcelTable.CST

FROM tbSupplierMaster

INNER JOIN OPENROWSET('Microsoft.ACE.OLEDB.12.0',

'Excel 12.0;Database=C:\Users\Public\Documents\DemoUpdate.xlsx;',

'SELECT SupplierIDp, SupplierCode, SupplierName, TinNo, CST FROM [Sheet1$]') AS ExcelTable

ON YourTable.ID = ExcelTable.ID

WHERE (tbSupplierMaster.SupplierIDp = ExcelTable.SupplierIDp

)

COMMIT

-- Insert statements for procedure here

END

GO

 But when i run this query then i get the following errors:
 
Msg 7308, Level 16, State 1, Procedure usp_undateSupplierandaddress, Line 17
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.
 
Please give me any kind of solution ..
 
 
Thanks in Advance
 
KP Singh
 
 
 
 
Answers (8)
2
K P  Singh Chundawat

K P Singh Chundawat

776 1k 213.2k 10y
Thanks for replying Nimit Joshi. Nice Article by you ..but it's not helpful for me .....Right now getting same problem .If you have any other solution then let me know ....
1
Nimit Joshi

Nimit Joshi

NA 26.9k 14.6m 10y
Do you have the Office driver for your office version?? If it is not installed please install it. You can get the reference from the following article:


http://www.c-sharpcorner.com/UploadFile/4b0136/connectivity-of-excel-2013-to-Asp-Net-web-application/
0
K P  Singh Chundawat

K P Singh Chundawat

776 1k 213.2k 10y
Yeah...Solved it using this .. Thanks for help me
0
Shweta Lodha

Shweta Lodha

20 48.6k 4.2m 10y
Hello KP Singh,
Is your problem solved?
0
K P  Singh Chundawat

K P Singh Chundawat

776 1k 213.2k 10y
Thank you
0
K P  Singh Chundawat

K P Singh Chundawat

776 1k 213.2k 10y
Thanks to reply me . Yeah I checked it. my MS office is 64 bit and MS SQL 2008 R2 also.
0
Shweta Lodha

Shweta Lodha

20 48.6k 4.2m 10y
KP Singh,
It may be bit-level issue. Please cross check your office, is it also 64 bit ?
SQL server and Office both should share the same architecture.