4 Replies - 1457 Views - Last Post: 24 February 2011 - 12:13 PM Rate Topic: -----

#1 bigbug   User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 97
  • Joined: 27-October 09

OLDB Connection throwing an error...

Posted 24 February 2011 - 11:10 AM

Not a student...
Hardware/Software: Win 7, 64bit, VS 2010 pro, Office 2010 / Access 2010
Operation: Trying to connect to Access 2010 database
Project Properties set to: Compile --> Target --> AnyCPU

I am getting the error "The 'Microsoft.ACE.OLEDB.12.0' Provider is not registered on the local machine." when I run this code: (Further explanation below)
Google and DIC searches have not turned up a significant fix.
The exception is thrown at the MyConn.Open() code.

Imports System.Data.OleDb

Module GlobalSubroutines
    Public Sub FillLabArray()

        Dim myConn As New OleDbConnection
        myConn.ConnectionString = "Provider=" & _
        strProvider & ";Data Source=" & strFile & ";"
        'MsgBox(myConn.ConnectionString)
        myConn.Open()'EXCEPTION THROWN HERE
        MsgBox("opened")
        Dim myCMD As OleDbCommand = New OleDbCommand
        myCMD.CommandText = "SELECT * FROM LAB"
        myCMD.Connection = myConn
        Dim myAdapter As OleDbDataAdapter = New OleDbDataAdapter
        myAdapter.SelectCommand = myCMD
        Dim ds As DataSet = New DataSet
        ds.Clear()
        myAdapter.Fill(ds, "LAB")
        Dim i As Integer
        LABcount = ds.Tables(0).Rows.Count - 1
        ReDim LABarray(27, LABcount)
        For i = 0 To LABcount
            LABarray(0, i) = ds.Tables(0).Rows(i).Item(0).ToString 'trcr
            LABarray(1, i) = ds.Tables(0).Rows(i).Item(1).ToString 'dte 
            LABarray(2, i) = ds.Tables(0).Rows(i).Item(2).ToString 'empcode
            LABarray(3, i) = ds.Tables(0).Rows(i).Item(3).ToString  ' fndn
            LABarray(4, i) = ds.Tables(0).Rows(i).Item(4).ToString  'hrs

            LABarray(5, i) = ds.Tables(0).Rows(i).Item(5).ToString 'emprate
            LABarray(6, i) = ds.Tables(0).Rows(i).Item(6).ToString 'PRJCODE
            LABarray(7, i) = ds.Tables(0).Rows(i).Item(7).ToString 'FNCN
            LABarray(8, i) = ds.Tables(0).Rows(i).Item(8).ToString 'OBJN
            LABarray(9, i) = ds.Tables(0).Rows(i).Item(9).ToString 'AMOUNT

            LABarray(10, i) = ds.Tables(0).Rows(i).Item(10).ToString 'WRKN
            LABarray(11, i) = ds.Tables(0).Rows(i).Item(11).ToString 'MNTH
            LABarray(12, i) = ds.Tables(0).Rows(i).Item(12).ToString 'AUDN 
            LABarray(13, i) = ds.Tables(0).Rows(i).Item(13).ToString 'FNDF
            LABarray(14, i) = ds.Tables(0).Rows(i).Item(14).ToString 'ACCF

            LABarray(15, i) = ds.Tables(0).Rows(i).Item(15).ToString ' INDAMT
            LABarray(16, i) = ds.Tables(0).Rows(i).Item(16).ToString 'EMPIND
            LABarray(17, i) = ds.Tables(0).Rows(i).Item(17).ToString 'OVRFCR
            LABarray(18, i) = ds.Tables(0).Rows(i).Item(18).ToString 'OVRHRS 
            LABarray(19, i) = ds.Tables(0).Rows(i).Item(19).ToString ' SHIFTFCR

            LABarray(20, i) = ds.Tables(0).Rows(i).Item(20).ToString ' SHIFTHRS
            LABarray(21, i) = ds.Tables(0).Rows(i).Item(21).ToString ' LABF
            LABarray(22, i) = ds.Tables(0).Rows(i).Item(22).ToString ' COMPHRS
            FNDN = LABarray(3, i)
            Call FNDseek()
            LABarray(23, i) = FNDD 'FNDD

            FNCN = LABarray(7, i)
            Call FNCseek()
            LABarray(24, i) = FNCD 'FNCD

            OBJN = LABarray(8, i)
            Call OBJseek()
            LABarray(25, i) = OBJD 'OBJD

            PRJN = LABarray(6, i)
            Call PRJseek()
            LABarray(26, i) = PRJD 'PRJD
            LABarray(27, i) = PRJT 'TYPE

        Next i
        myConn.Close()
        myConn.Dispose()
        myAdapter.Dispose()
        ds.Dispose()

    End Sub

<---- CLIPPED HERE, NOTHING RELEVANT BELOW ---->

THIS IS IN ANOTHER MODULE TO FILL THE VARIABLES...

Imports System.Data.OleDb
Module Globals
    Public Const strProvider As String = "Microsoft.ACE.OLEDB.12.0"

    Public Const strFile = "C:\HWYDATA\DWARE.accdb"


    Public giDebug As Integer = 0 ' set gidebug 1 if trying to debug system
    '------------ Variables for a public Dataset ------
    Public ds As New DataSet

    Public dt As New DataTable("dtTable")

<---- CLIPPED HERE, NOTHING RELEVANT BELOW ---->




The code below works the PERFECT on the same system as a stand alone test application. Compile options are the same.

Imports System.Data.OleDb

Module Module1
    Public Sub FillLabArray()
        Const strProvider As String = "Microsoft.ACE.OLEDB.12.0"
        Dim myConn As New OleDbConnection
        Dim strFile As String
        strFile = "C:\HWYDATA\DWARE.accdb"
        myConn.ConnectionString = "Provider=" & _
        strProvider & ";Data Source=" & strFile & ";"
        MsgBox(myConn.ConnectionString)
        myConn.Open()
        MsgBox("myconn open")
        Dim myCMD As OleDbCommand = New OleDbCommand
        myCMD.CommandText = "SELECT * FROM LAB"
        myCMD.Connection = myConn
        Dim myAdapter As OleDbDataAdapter = New OleDbDataAdapter
        myAdapter.SelectCommand = myCMD
        Dim ds As DataSet = New DataSet
        ds.Clear()
        myAdapter.Fill(ds, "LAB")
        Dim i As Integer
        Dim txt As String
        For i = 0 To ds.Tables(0).Rows.Count - 1
            txt = ds.Tables(0).Rows(i).Item(0).ToString
            MsgBox(txt)
        Next i
        
    End Sub

End Module




It should be noted that the BOTH code listings work correctly and error free on my business partners machine, also a Win 7, 64bit with the same current software installed.

Anyone have any ideas?

Thank you.

BIGBUG

Is This A Good Question/Topic? 0
  • +

Replies To: OLDB Connection throwing an error...

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14768
  • View blog
  • Posts: 59,038
  • Joined: 12-June 08

Re: OLDB Connection throwing an error...

Posted 24 February 2011 - 11:26 AM

http://social.techne...90-d8ff3f962724

Try flipping your cpu to x86. It sounds like it is trying to build for a 64bit driver that doesn't exist except as 32bit.

The error is telling you it can't find the file in the GAC (global assembly cache).
Was This Post Helpful? 0
  • +
  • -

#3 bigbug   User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 97
  • Joined: 27-October 09

Re: OLDB Connection throwing an error...

Posted 24 February 2011 - 11:32 AM

View Postmodi123_1, on 24 February 2011 - 11:26 AM, said:

http://social.techne...90-d8ff3f962724

Try flipping your cpu to x86. It sounds like it is trying to build for a 64bit driver that doesn't exist except as 32bit.

The error is telling you it can't find the file in the GAC (global assembly cache).


Thanks for the tip modi, I will take a look at the link and of course try the suggestion but it does not explain away why the second program runs error free... I think that is bugging me the most lol.

Bigbug
Was This Post Helpful? 0
  • +
  • -

#4 marinus   User is offline

  • D.I.C Addict
  • member icon

Reputation: 138
  • View blog
  • Posts: 575
  • Joined: 14-April 10

Re: OLDB Connection throwing an error...

Posted 24 February 2011 - 11:41 AM

Have you looked at this thread

May Be 64bit issue according to this link


Hope this helps
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14768
  • View blog
  • Posts: 59,038
  • Joined: 12-June 08

Re: OLDB Connection throwing an error...

Posted 24 February 2011 - 12:13 PM

It could be your GACs are different. IIS is setup different... etc. There's a lot of problems that could be "the one".

My guess is your Ace driver is not the same in both GACs.

I would advocate installing the Acess 2007 database drivers to your GAC and see how that rolls.
http://www.microsoft...&displayLang=en

FYI Ace and Jet are distributed with the versions of Access.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1