Microsoft KB Archive/942977

= Error message when you bind a DataGridView control to an Access database in Microsoft Visual Studio 2005: &quot;System.InvalidOperationException occurred Message=&quot;The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.&quot;&quot; =

Article ID: 942977

Article Last Modified on 1/7/2008

-

APPLIES TO


 * Microsoft Visual Studio 2005 Express Edition
 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio 2005 Team Edition for Database Professionals
 * Microsoft Visual Studio 2005 Team Edition for Software Architects
 * Microsoft Visual Studio 2005 Team Edition for Software Developers
 * Microsoft Visual Studio 2005 Team Edition for Software Testers
 * Microsoft Visual Studio 2005 Team Suite
 * Microsoft Visual Studio 2005 Team System Test Edition

-



SYMPTOMS
Consider the following scenario:
 * You have a Windows Form application in Microsoft Visual Studio 2005 on a computer that is running Windows Vista 64-bit edition.
 * You create a DataGridView control. Then, you bind the DataGridView control to a Microsoft Access database.
 * You run the application.

In this scenario, you may receive the following error message:

System.InvalidOperationException occurred

Message=&quot;The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.&quot;

Source=&quot;System.Data&quot;



CAUSE
This problem occurs because there is no 64-bit version of the Microsoft.Jet.OLEDB.4.0 database provider.



WORKAROUND
To work around this problem, use one of the following methods.

Method 1
Force the application to be compiled as a 32-bit application. To do this, follow the steps in the appropriate section.

Steps for Microsoft Visual C# projects

 * 1) In Solution Explorer, right-click the application, and then click Properties.
 * 2) Click the Build tab.
 * 3) In the Platform target list, click x86.
 * 4) On the File menu, click Save Selected Items.

Steps for Microsoft Visual Basic projects

 * 1) In Solution Explorer, right-click the application, and then click Properties.
 * 2) Click the Compile tab.
 * 3) On the Compile tab, click Advanced Compile Options.
 * 4) In the Advanced Compiler Settings dialog box, click x86 in the Target CPU list, and then click OK.
 * 5) On the File menu, click Save Selected Items.

Method 2
Use Microsoft SQL Server Express Edition instead of Access. The benefits of using SQL Server Express Edition are as follows:
 * You can use the 64-bit version of SQL Native Client to connect to SQL Server Express Edition. SQL Native Client contains the SQL Server OLE DB provider and the SQL Server ODBC driver.
 * SQL Server Express Edition is free.
 * Only a 32-bit version of SQL Server Express Edition is available. However, you can still use the 64-bit version of SQL Native Client in the application to connect to SQL Server Express Edition.

To obtain SQL Server 2005 Express Edition, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/express/bb410792.aspx



MORE INFORMATION
The Target CPU option for Visual Basic projects or the Platform target option for Visual C# projects determines which version the application is compiled as. By default, these options are set to the Any CPU value. Therefore, on a 64-bit version of Windows Vista, this application is compiled as a 64-bit application. On a 32-bit version of Windows Vista, this application is compiled as a 32-bit application.

Call stack information
at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper) at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at WindowsApplication1.northwindDataSetTableAdapters.EmployeesTableAdapter.Fill(EmployeesDataTable dataTable) in C:\Documents and Settings\marcro\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\northwindDataSet.Designer.vb:line 1349 at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\marcro\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb:line 12

Keywords: kbexpertiseadvanced kbtshoot kbprb KB942977

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.