connecting a visual basic 2008 express program to microsoft access 2003 in 64 bit operating system

StackOverflow https://stackoverflow.com/questions/19657489

Pregunta

I am working on an experimental project and have run into a problem trying to connect a microsoft access database to my program in visual basic 2008 express and keep getting the following message when I try to make the connection.

"The 'Microsoft.Jet.OLEDB.4.0C:\Users\lewis\Documents\programming\programs\cadet stores program\squadron stores system V1.1\squadron stores system V1.1\stores database\213 squadron stores.mdb' provider is not registered on the local machine."

After some research I have seen that there may be an issue because I am using a 64 bit operating system with 32 bit software. Any help or suggestions I would be grateful

This is the method I am currently trying to use:

Dim con As New OleDb.OleDbConnection
    Dim dbProvider As String
    Dim dbSource As String

    dbProvider = "Provider=Microsoft.Jet.OLEDB.4.0"
    dbSource = "C:\Users\lewis\Documents\programming\programs\cadet stores program\squadron stores system V1.1\squadron stores system V1.1\stores database\213 squadron stores.mdb"

    con.ConnectionString = dbProvider And dbSource
    con.Open()

I have now re written the syntax as shown bellow:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim con As New OleDb.OleDbConnection
    Dim connString As String

    connString = "Provider = Microsoft.Jet.OLEDB.4.0;"
    connString &= "C:\Users\lewis\Documents\programming\programs\cadet stores program\squadron stores system V1.1\squadron stores system V1.1\stores database\213 squadron stores.mdb;"
    con.ConnectionString = connString

    con.Open()

    MessageBox.Show("Conection open")

End Sub

However I now get the following error message:

"Format of the initialization string does not conform to specification starting at index 35."

The connection now works many thanks for your help

many thanks

Lewis

¿Fue útil?

Solución

This is just wrong:

' And does not concatenate strings
con.ConnectionString = dbProvider And dbSource

what you probably meant was:

con.ConnectionString = dbProvider & ";" & dbSource

or

connString = "Provider=Microsoft.Jet.OLEDB.4.0; "   ' end with a ;
connString &= "Data Source = C:\Users\lewis..."

con.ConnectionString = connString   

I am using a 64 bit operating system with 32 bit software If this means your project is 32 bit, you shouldn't have a problem, but for info on using OLEDb 4.0 in 64bit mode look here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top