Re: get DB path from ADODB.Connection



Yes, you are right I don't need to loop through all the
properties. This was just left over from some testing code.

RBS

"Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx> wrote in message news:%23XSlTPL8GHA.788@xxxxxxxxxxxxxxxxxxxxxxx
It appears that the number of properties of the connection object varies. However, rather than enumerating all, you can reference the one you want by name. For example:

Wscript.Echo ADOConn.Properites("Extended Properties").Value
or
arr = Split(ADOConn.Properties("Extended Properites").Value, ";")

If there is more than one "Extended Properities", they apparently are delimited by semicolons. However, the value of this property depends on the provider. You may have to consult Interbase documentation.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"RB Smissaert" <bartsmissaert@xxxxxxxxxxxxxxxx> wrote in message news:ejj5omK8GHA.1496@xxxxxxxxxxxxxxxxxxxxxxx
Actually, it seems quite simpel:

Function GetDBPathFromADOConn() As String

Dim i As Long
Dim n As Long
Dim arr
Dim lEqualPos As Long

If Not ADOConn Is Nothing Then
If ADOConn.State = 1 Then
'step back as the index is 86 out of 91
'not sure this always will be the case
'--------------------------------------
For i = ADOConn.Properties.count - 1 To 0 Step -1
If ADOConn.Properties(i).Name = "Extended Properties" Then
'is the ; character always the separator?
'----------------------------------------
arr = Split(ADOConn.Properties(i).Value, ";")
For n = 0 To UBound(arr)
If UCase(InStr(1, UCase(arr(n)), ".GDB", vbBinaryCompare))
> 0 Then
lEqualPos = InStr(1, arr(n), "=", vbBinaryCompare)
If lEqualPos = 0 Then
GetDBPathFromADOConn = arr(n)
Else
GetDBPathFromADOConn = Mid$(arr(n), lEqualPos + 1)
End If
Exit For
End If
Next
End If
Next
End If
End If

End Function


Not sure though if this always will work.

RBS


"RB Smissaert" <bartsmissaert@xxxxxxxxxxxxxxxx> wrote in message news:uA$t7DK8GHA.2384@xxxxxxxxxxxxxxxxxxxxxxx
Using VBA in Excel and connecting to an Interbase database via ODBC and ADO.
Is it possible to get the full DB path from the ADODB.Connection object?

There is no problem if I set the DB path in code in a set connection string, but the problem is
with a DSN connection like this:

strConn = "DSN=System 6000;" & _
"UID=" & Username & ";" & _
"PWD=" & Password
ADOConn.Open strConn

I just need a foolproof way of getting the DB path from the current ADO connection.

RBS






.



Relevant Pages

  • Re: get DB path from ADODB.Connection
    ... It appears that the number of properties of the connection object varies. ... Dim i As Long ... Dim lEqualPos As Long ...
    (microsoft.public.data.ado)
  • Re: Updating Access data using SQL / refresh time question
    ... As a test today, for one poarticular recordset, I changed from DAO to ADO to ... > I forgot to mention that the expense of repeated connection open and close ... > dim oconn as new adodb.connection ... > 'Now load the listview by looping through each RS row ...
    (microsoft.public.vb.database)
  • Re: Updating Access data using SQL / refresh time question
    ... > I forgot to mention that the expense of repeated connection open and close ... > dim oconn as new adodb.connection ... > 'Now load the listview by looping through each RS row ... > ' Set the recordset object each time we load the listview ...
    (microsoft.public.vb.database)
  • Re: Updating Access data using SQL / refresh time question
    ... > I forgot to mention that the expense of repeated connection open and close ... > dim oconn as new adodb.connection ... > 'Now load the listview by looping through each RS row ... > ' Set the recordset object each time we load the listview ...
    (microsoft.public.vb.database)
  • Re: making datareaders
    ... ''' This is set in the connection string by setting the ... Dim myAddressReader As SqlDataReader ... Dim myFinalString As String = "" ...
    (microsoft.public.dotnet.languages.vb)