check for OLE DB provider?

C

cesw

I am working in Excel 2000 VB 6.0 with an Oracle 9.2 client
Some of the users have Excel 2002 or 2003, VB 6.3, and/or Oracle 8i or
9i clients.
So far, everyone has been able to use either MSDAORA.1 or
oraOLEDB.Oracle for the connection string provider.

Rather than hard-coding the provider, and maintaining multiple versions
of the code, and lists of who has what, which could change with an
upgrade, is there a way to check which dll the user has, and then set
the provider from that?

Thanks!
 
G

Guest

Hi,

I used to have to deal with the similar situation of various Oracle clients
and Excel versions. You can trap and handle the error raised if the relevant
OLE DB provider is not present. For example when MSDAORA.1 is not present,
error code -2147467259 is raised with the following description...

"Oracle client and networking components were not found. These components
are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3
or later client software installation.

Provider is unable to function until these components are installed."

When OraOLEDB.Oracle.1 is not present, error code 3706 is raised with the
description: "Provider cannot be found. It may not be properly installed."

The following code may not be super-elegant, but worked just fine for me
over many years...

Sub OpenMyOracleConnection()
Dim cnn As New ADODB.Connection
Dim strCnn As String
Dim iTry As Integer

strCnn = "Provider=MSDAORA.1;Password=<pwd>;User ID=<userID>;Data
Source=<dbName>;Persist Security Info=True"
' Enter your own specific user and environment info between the angle
brackets
iTry = 1
On Error GoTo Err_ADOError
' Open the Connection
cnn.Open strCnn
On Error GoTo 0

Application.StatusBar = "ADODB connection successfully opened..."

' <Insert your code here>

Application.StatusBar = False
Exit Sub

Err_ADOError:
Select Case Err.Number
Case -2147467259, 3706 ' OLE DB provider is probably missing (MSDAORA.1
or OraOLEDB.Oracle.1 respectively)
strCnn = "Provider=OraOLEDB.Oracle.1;Password=<pwd>;User
ID=<userID>;Data Source=<dbName>;Persist Security Info=True"
' Enter your own specific user and environment info between the angle
brackets as above
If iTry < 2 Then
iTry = iTry + 1
Resume
Else
Exit Sub
End If
Case Else
MsgBox Err.Number & ": " & Err.Description & vbCrLf & vbCrLf &
"Application will now terminate."
Application.StatusBar = False
End Select
End Sub

Trust this helps and let me know how you get on.

Good Luck, Sean.
 
C

cesw

Sean - Thanks for responding.

We decided to upgrade the users client to 9i, thinking that was why
they needed OraOLEDB.Oracle provider while those already on 9i were
using MSDAORA provider.

Unfortunately, the issue seems to also be related to the version of
Excel.
With 2000, MSDAORA works; it does not with Excel 2003.

Could this be related to different versions of MDAC?
The Excel 2003 users have 2.8 while the Excel 2000 users have 2.7
(I think - is there a way to verify this, or is it irrelevant?)

The OraOLEDB.Oracle provider does not work with 9i (it seems the OLE
and ODBC components are not part of the standard client
installation...)

Any suggestions are greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top