Solved

MS VBA AODBC Run-time Error

Posted on 2007-03-26
4
356 Views
Last Modified: 2013-12-25
I'm trying to use the Microsoft ActiveX Data Objects 2.8 Library to establish a connection to a Sybase database.  I have successfully used the XLODBC.XLA driver on the same computer, so I believe the ODBC connection is set up properly.  This is using Excel 2000 and Windows 2000 Professional.

I am getting the following error when I try to set the connection:
     Run-time error '-2147024769 (8007007f)':
     Automation error
     The specified procedure could not be found.

However, the library is selected in the VBA References list.  Here is my code; the error is generated on line 13 (commented accordingly):

     Sub testSQL()

     Dim uidA, pwdA As String
     dsnA = InputBox("Data Server Name:")
     uidA = InputBox("DB User ID:")
     pwdA = InputBox("DB Password:")
     
     Dim conn As ADODB.Connection
     Dim connStr As String
     Dim rs As ADODB.Recordset
     
     connStr = "DSN="& dsnA & ";UID=" & uidA & ";PWD=" & pwdA & ";"
     Set conn = New ADODB.Connection     '<---- This is the line that generates the error message
     conn.Open connStr
     conn.Close
     Set conn = Nothing

     End Sub

Does anyone know what might be causing this error?  Thanks in advance for the help.
0
Comment
Question by:davidjt61983
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Christopher Kile earned 500 total points
ID: 18795105
After consulting several references and finding a mishmash of ideas for solving this, I'm reduced to two suggestions:  either reinstall MDAC 2.8, or attempt to identify and re-register each and every DLL it uses.  I recommend this because it seems that while the system can find the object (otherwise you would have gotten an object not found error), the interface definitions have become corrupted somehow, so that it can't find the constructor method.

As an alternative, you can try CreateObject("ADODB.Connection") and see if it instantiates properly.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 18810075
In Excel go to your code window then Tools/References.  Is the following one of the checked items?

Microsoft ActiveX Data Objects 2.8 Library?

If it is, try unchecking, close the dialog box, then go back and check it again.  If that does not work try library 2.7

Leon
0
 

Author Comment

by:davidjt61983
ID: 18815739
Thanks for your help.

It took a day to get the package re-installed due to office policies, etc.  I am now able to establish a connection.
0
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 18816351
yvw :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now