accdb' provider is not registered

viper5646

Active member
Joined
Jan 20, 2009
Messages
38
Location
Canada
Programming Experience
Beginner
Hi I hope there is some one can help me with this error "The 'Microsoft.Jet.OLEDB.4.0Data Source=C:\DEsign.accdb' provider is not registered on the local machine."
This occurs when it tries to open the DataBase. This the code.
VB.NET:
Public Class MainForm
    Private m_cnADONetConnection As New OleDb.OleDbConnection
    Private m_daDataAdapter As OleDb.OleDbDataAdapter
    Private m_cbCommandBuilder As OleDb.OleDbCommandBuilder
    Private m_dtDEsign As New DataTable
    Private m_rowPosition As Integer = 0


    Private Sub MainForm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        m_cnADONetConnection.Close()
        m_cnADONetConnection.Dispose()
    End Sub
    Private Sub ShowCurrentRecord()

        MessageBox.Show(m_dtDEsign.Rows.Count)
        If m_dtDEsign.Rows.Count = 0 Then
            txtContactName.Text = ""
            txtState.Text = ""
            Exit Sub
        End If
        MessageBox.Show(m_dtDEsign.Rows(m_rowPosition)("Order Entry").ToString)
        txtContactName.Text = m_dtDEsign.Rows(m_rowPosition)("Order Entry").ToString()
        txtState.Text = m_dtDEsign.Rows(m_rowPosition)("Address").ToString()
       
    End Sub

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        m_cnADONetConnection.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0" & "Data Source=C:\DEsign.accdb"
        m_cnADONetConnection.Open()
        m_daDataAdapter = New OleDb.OleDbDataAdapter("select * From Design", m_cnADONetConnection)
        m_cbCommandBuilder = New OleDb.OleDbCommandBuilder(m_daDataAdapter)
        m_daDataAdapter.Fill(m_dtDEsign)
        Me.ShowCurrentRecord()

    End Sub
 
That's because the Jet 4.0 driver doesn't understand the Ace 12 file format (aka the Jet 4.0 driver can't read/write to the *.accdb file) What you need to do is install the Ace 12 driver (which does support everything the jet 4.0 driver can, so it's backwards compatible) the Ace 12 driver can be gotten here: Download details: 2007 Office System Driver: Data Connectivity Components

and you use the Ace 12 connection string in your apps:
VB.NET:
 "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword;"
Other examples are here: Access 2007 connection string samples - ConnectionStrings.com
 
Back
Top