Microsoft is not registered on the local computer. ace.oledb.12.0 "Provider

Source: Internet
Author: User
Tags odbc ole stack trace

error message: Microsoft is not registered on the local computer. ace.oledb.12.0 "provider.

Workaround: http://download.microsoft.com/download/7/0/3/703ffbcb-dc0c-4e19-b0da-1463960fdcdb/AccessDatabaseEngine.exe Download and install.

cause of error: An error occurred because the database that was built with the ACCESS2007 version was used, but there were no programs in the server that were used together.

error message: Microsoft is not registered on the local computer. ace.oledb.12.0 "provider.

Workaround: An unhandled exception occurred during the execution of the current WEB request.  Check the stack trace information For more information about the error and the source of the error in your code.

error message: Exception Details: System.InvalidOperationException: Microsoft is not registered on the local computer. ace.oledb.12.0 "provider.

Workaround: Download the Office system driver: Data Connection Component Installation http://download.microsoft.com/download/7/0/3/ 703ffbcb-dc0c-4e19-b0da-1463960fdcdb/accessdatabaseengine.exe

This download installs a set of components that non-Microsoft Office applications can use to read data from the Office system files, such as the Microsoft office Access (MDB and accdb) files and the Mic Rosoft read data in Office Excel (xls, xlsx, and xlsb) files. These components also support establishing connections to Microsoft Windows SharePoint Services and text files. In addition, ODBC and OLE DB drivers are installed for application developers to use when developing applications that are connected to the Office file format.

If you are an application developer who uses OLE DB , set the Provider parameter of the ConnectionString property to "microsoft.ace.oledb.12.0". If you want to connect to Microsoft Office Excel data, add Excel 12.0 to the extended properties of the OLE DB connection string.

If you are an application developer who uses ODBC to connect to Microsoft Office Access data, set the connection string to "Driver={microsoft Access Driver (*.mdb, *.accdb) };D Bq=path to mdb/accdb file "

If you are an application developer who uses ODBC to connect to Microsoft Office Excel data, set the connection string to "Driver={microsoft Excel Driver (*.xls, *.xlsx, *.x LSM, *.XLSB)};D bq=path to xls/xlsx/xlsm/xlsb file "details:http://www.microsoft.com/downloads/zh-cn/details.aspx? displaylang=zh-cn&familyid=7554f536-8c28-4598-9b72-ef94e038c891

Or: Workaround 1 (verify Yes)

Select an application pool for the application------> select Advanced Settings---------> Enable 32-bit applications------->true

Solution 2

Microsoft.ace.oledb.12.0 can not be used again x64, you want to force your Web application compiled into x86 and then released to Win08 x64, remember to set the Enable 32bit on the application pool Application = True. (No validation)

Operation Code:

        Private voidOpentoolstripmenuitem_click (Objectsender, EventArgs e) {OpenFileDialog Opendialg=NewOpenFileDialog (); //Opendialg.showdialog ();opendialg.initialdirectory="C:\\users\\administrator\\desktop"; Opendialg.filter="Excel Files (2003-2007) |*.xls| Excel File (*.xlsx) |*.xlsx| All Files (*. *) |*.*"; Opendialg.title="Open Excel File"; Opendialg.filterindex=0; Opendialg.restoredirectory=true;            OleDbDataAdapter da; DataSet DS=NewDataSet (); if(Opendialg.showdialog () = =DialogResult.OK) {if(string. IsNullOrEmpty (Opendialg.filename)) {MessageBox.Show ("Please select an Excel file! "); DT=NULL; }                Else                {                    Try{                        stringFilename=opendialg.filename.substring (OpenDialg.FileName.LastIndexOf ('.')); stringConnstr=""; Switch(FileName) { Case ". xls": {connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data source="+ Opendialg.filename +"; Extended properties= ' Excel 8.0; Hdr=yes;imex=1 '";  Break; }                             Case ". xlsx": {connstr="Provider=microsoft.ace.oledb.12.0;data source="+ Opendialg.filename +"; Extended properties= ' Excel 12.0; hdr=yes;imex=1; '";  Break; }                            default: {connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data source="+ Opendialg.filename +"; Extended properties= ' Excel 8.0; Hdr=yes;imex=1 '";  Break; }                        }                        //Excel data is stored in a DataTable after it is read in                        stringSql="SELECT * from["+getexcelfirsttablename (OPENDIALG.FILENAME,CONNSTR) [0]. ToString (). Trim () +"]"; OleDbConnection con=NewOleDbConnection (CONNSTR); Con.                        Open (); Da=NewOleDbDataAdapter (Sql,con); Da.                        Fill (DS); if(ds. tables[0]. rows.count==0)                        {                            //Open File content is empty, continue to leave DataTable emptyMessageBox.Show ("There is no data in the selected file"); DT=NULL; }                        Else                        {                            //open file is not emptyDt=ds. tables[0]; //display DT in Datagridviewe                             This. datagridview_excel.datasource=DT; }                        //return DT;                    }                    Catch(Exception exp) {MessageBox.Show (exp.                        Message.tostring ()); //return DT; //This.datagridview_excel.datasource=dt; //This.dataGridView_Excel.Rows.Add (DT.                        Rows[0].) //While (this.dataGridView_Excel.Rows)                    }                //StreamReader Sr=file.opentext (opendialg.filename); //While (Sr. Endofstream!=true)//{                //FileStream FileStream = new FileStream (); //Ifilereaderservice//}            }        }    }

/// <summary>        ///gets the name of the first sheet/// </summary>        /// <param name= "Excelfilename" >Excel file name</param>        /// <param name= "strextension" >reading data connections for Excel file data</param>        /// <returns></returns>        Private StaticArrayList Getexcelfirsttablename (stringExcelfilename,stringstrextension) {ArrayList tablenamelist=NewArrayList (); Try            {                if(File.exists (excelfilename)) {using(OleDbConnection conn =NewSystem.Data.OleDb.OleDbConnection (strextension)) {Conn.                        Open (); DataTable DT= Conn. GetOleDbSchemaTable (OleDbSchemaGuid.Tables,NULL); Tablenamelist.add (DT. rows[0][2]. ToString ().                        Trim ()); returntablenamelist; }                }            }            Catch(Exception exp) {MessageBox.Show (exp.            Message.tostring ()); }            returntablenamelist; }

Microsoft is not registered on the local computer. ace.oledb.12.0 "Provider

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.