Completely stumped... Error thrown: System.Data.OleDb.OleDbException: 'Unrecognized database format

0

I have a 32bit version of office, and I am using "any cpu".

The very curious part about this error is that my program was working fine before this happened. It seemed to throw this error out of the blue to be honest, I did not make any major changes.

Here is my code. The error is thrown at Cnn.Open().

Imports System.Data.OleDb

Public Class MainWindow
    Dim provider As String
    Dim dataFile As String
    Dim connString As String
    Dim myConnection As OleDbConnection = New OleDbConnection
    Dim addedBonuses As New DataTable

Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
    'Change the following to your access database location
    dataFile = "C:\Users\mousaghannnam\source\repos\CampbellBonuses\CampbellBonuses\CampbellBonuses.accdb;"
    connString = provider & dataFile

    'For Employee Information
    Dim cnn As New OleDb.OleDbConnection
    Dim cmd As New OleDb.OleDbCommand
    Dim da As New OleDb.OleDbDataAdapter
    cnn.ConnectionString = connString

    'For Incentives Information
    Dim cnn2 As New OleDb.OleDbConnection
    Dim cmd2 As New OleDb.OleDbCommand
    Dim da2 As New OleDb.OleDbDataAdapter
    cnn2.ConnectionString = connString
    cnn.Open()

Here are the details of the error.

HResult=0x80004005
  Message=Unrecognized database format 'C:\Users\mousaghannnam\source\repos\CampbellBonuses\CampbellBonuses\CampbellBonuses.accdb'.
  Source=System.Data
  StackTrace:
   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at CampbellBonuses.MainWindow.Form1_Load(Object sender, EventArgs e) in C:\Users\mousaghannnam\source\repos\CampbellBonuses\CampbellBonuses\Form1.vb:line 28
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

If anybody knows why this could be going on, I would be greatly appreciative.

vb.net
oledbconnection
asked on Stack Overflow Sep 3, 2018 by mousadafousa • edited Sep 3, 2018 by Lennart

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0