13 Replies - 320 Views - Last Post: 08 January 2019 - 01:31 AM Rate Topic: -----

#1 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 80
  • Joined: 30-August 15

VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 02:11 PM

I followed this tutorial: https://www.youtube....h?v=UtE3kkQR7_w

I have a database named Database2.accdb just like the tutorial (with columns matching the ones in the video as well).

Here is my code:

Imports System.Data.OleDb

Public Class Form1

    Dim provider, dataFile, connString As String
    Dim myConnection As OleDbConnection = New OleDbConnection

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        provider = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=“

        'Name of your Database Access file, Database2.accdb
        dataFile = “D:\Database2.accdb”
        connString = provider & dataFile
        myConnection.ConnectionString = connString
        myConnection.Open()
        Dim str As String
        str = “Insert into Items([InvoiceID],[Item],[Cost],[Quantity]) Values (?,?,?,?)”
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)

        '1 for each column in the Access file.
        cmd.Parameters.Add(New OleDbParameter(“InvoiceID”, CType(TextBox1.Text, String)))
        cmd.Parameters.Add(New OleDbParameter(“Item”, CType(TextBox2.Text, String)))
        cmd.Parameters.Add(New OleDbParameter(“Cost”, CType(TextBox3.Text, String)))
        cmd.Parameters.Add(New OleDbParameter(“Quantity”, CType(TextBox4.Text, String)))
    End Sub

End Class




I have also attached a picture of the error that I always get when I select the "Submit" button.

Any thoughts?

Attached image(s)

  • Attached Image

This post has been edited by geos59: 06 January 2019 - 02:15 PM


Is This A Good Question/Topic? 0
  • +

Replies To: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,718
  • Joined: 12-June 08

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 02:22 PM

Do you have 'Microsoft.ACE.OLEDB.12.0' installed?

Redistribute for Ace: https://Microsoft.AC...s.aspx?id=13255
Was This Post Helpful? 1
  • +
  • -

#3 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 80
  • Joined: 30-August 15

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 03:39 PM

View Postmodi123_1, on 06 January 2019 - 02:22 PM, said:

Do you have 'Microsoft.ACE.OLEDB.12.0' installed?

Redistribute for Ace: https://Microsoft.AC...s.aspx?id=13255


Dead link, I assume you mean this? https://www.microsof...s.aspx?id=13255
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,718
  • Joined: 12-June 08

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 04:30 PM

Sure.
Was This Post Helpful? 0
  • +
  • -

#5 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 80
  • Joined: 30-August 15

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 05:33 PM

View Postmodi123_1, on 06 January 2019 - 04:30 PM, said:

Sure.


It got rid of that problem, thanks!

But now a new problem arises:

System.Data.OleDb.OleDbException: 'The Microsoft Access database engine cannot open or write to the file ______________. It is already opened exclusively by another user, or you need permission to view and write its data.'
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,718
  • Joined: 12-June 08

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 06:00 PM

Is another app using it? Try putting the db file in the bin directory.
Was This Post Helpful? 0
  • +
  • -

#7 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 80
  • Joined: 30-August 15

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 06:06 PM

View Postmodi123_1, on 06 January 2019 - 06:00 PM, said:

Is another app using it? Try putting the db file in the bin directory.


No app (that I know of) is using it also.

Putting it in the bin directory didn't change it sadly, but when I was experimenting with the "provider" string connection; I now have a new error (picture attached).

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#8 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,025
  • Joined: 05-December 13

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 06:21 PM

Please show your current code
Was This Post Helpful? 0
  • +
  • -

#9 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 80
  • Joined: 30-August 15

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 06 January 2019 - 07:48 PM

View PostSheepings, on 06 January 2019 - 06:21 PM, said:

Please show your current code


Fair enough.

Imports System.Data.OleDb

Public Class Form1

    Dim provider, dataFile, connString As String
    Dim myConnection As OleDbConnection = New OleDbConnection

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        provider = "Microsoft.ACE.OLEDB.12.0;Data Source= Persist Security Info=False"

        'Name of your Database Access file, Database2.accdb
        dataFile = “C:\Users\George\Desktop\SignInPractice\SignInPractice\bin”
        connString = provider & dataFile
        myConnection.ConnectionString = connString
        myConnection.Open()
        Dim str As String
        str = “Insert into Items([InvoiceID],[Item],[Cost],[Quantity]) Values (?,?,?,?)”
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)

        '1 for each column in the Access file.
        cmd.Parameters.Add(New OleDbParameter(“InvoiceID”, CType(TextBox1.Text, String)))
        cmd.Parameters.Add(New OleDbParameter(“Item”, CType(TextBox2.Text, String)))
        cmd.Parameters.Add(New OleDbParameter(“Cost”, CType(TextBox3.Text, String)))
        cmd.Parameters.Add(New OleDbParameter(“Quantity”, CType(TextBox4.Text, String)))
    End Sub

End Class



Was This Post Helpful? 0
  • +
  • -

#10 andrewsw   User is offline

  • dependency injected
  • member icon

Reputation: 6668
  • View blog
  • Posts: 27,308
  • Joined: 12-December 12

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 07 January 2019 - 01:30 AM

Please describe what you think an error means, don't just post an error message.

Looking at your provider string, it is unlikely that 'Persist Security Info' is a Data Source.



Also, please copy and paste original code directly from your programming editor or IDE (the curly quotes indicate that the posted code has been through some other kind of editor).
Was This Post Helpful? 0
  • +
  • -

#11 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 80
  • Joined: 30-August 15

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 07 January 2019 - 05:25 PM

View Postandrewsw, on 07 January 2019 - 01:30 AM, said:

Please describe what you think an error means, don't just post an error message.

Looking at your provider string, it is unlikely that 'Persist Security Info' is a Data Source.



Also, please copy and paste original code directly from your programming editor or IDE (the curly quotes indicate that the posted code has been through some other kind of editor).


Okay I fixed the connection string. I've been using this site as a reference (https://www.connectionstrings.com/access/)

Here's my fix:

Imports System.Data.OleDb

Public Class Form1

    Dim provider, dataFile, connString As String
    Dim myConnection As OleDbConnection = New OleDbConnection

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        provider = "Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\GeorgeT\Desktop\SignInPractice\SignInPractice\bin\Database2.accdb; Persist Security Info=False;"

        'Name of your Database Access file, Database2.accdb
        dataFile = "C:\Users\GeorgeT\Desktop\SignInPractice\SignInPractice\bin\Database2.accdb"
        connString = provider & dataFile
        myConnection.ConnectionString = connString
        myConnection.Open()
        Dim str As String
        str = "Insert into Items([InvoiceID],[Item],[Cost],[Quantity]) Values (?,?,?,?)"
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)

        '1 for each column in the Access file.
        cmd.Parameters.Add(New OleDbParameter("InvoiceID", CType(TextBox1.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Item", CType(TextBox2.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Cost", CType(TextBox3.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Quantity", CType(TextBox4.Text, String)))
    End Sub

End Class




Now I get this error "System.ArgumentException: 'Format of the initialization string does not conform to specification starting at index 141.'"

The error happens here: myConnection.ConnectionString = connString
Was This Post Helpful? 0
  • +
  • -

#12 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,718
  • Joined: 12-June 08

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 07 January 2019 - 06:57 PM

Are you missing the 'Provider=' before 'microsoft.ACE.OLEDB.12.0'?
Was This Post Helpful? 0
  • +
  • -

#13 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,025
  • Joined: 05-December 13

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 07 January 2019 - 07:47 PM

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
Persist Security Info=False;


And do you think your connection string is correct?

connString = provider & dataFile


When you combine provider ::

provider = "Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\GeorgeT\Desktop\SignInPractice\SignInPractice\bin\Database2.accdb; Persist Security Info=False;"


With ::

dataFile = "C:\Users\GeorgeT\Desktop\SignInPractice\SignInPractice\bin\Database2.accdb"


What does it output?

If that were correct, you have no ;

After that, compare them with the first quoted code above. What's the difference?
Was This Post Helpful? 0
  • +
  • -

#14 andrewsw   User is offline

  • dependency injected
  • member icon

Reputation: 6668
  • View blog
  • Posts: 27,308
  • Joined: 12-December 12

Re: VB.NET error, Microsoft.ACE.OLEDB.12.0 provider is not registered.

Posted 08 January 2019 - 01:31 AM

As already mentioned, when posting an error describe what you think the problem might be and what steps you have taken to investigate. Just posting an error without any additional information does not encourage participation.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1