TD Driver Name in VBA connection string

Connectivity
Enthusiast

TD Driver Name in VBA connection string

Is there an option to find the Teradata driver name and pass that in VBA through a variable?  We have various users with different Teradata versions and Driver names. and hence wondering if there is anyway to find out the Driver name prior to passing it in a connection string.


Accepted Solutions
Teradata Employee

Re: TD Driver Name in VBA connection string

A good question. In the past, the driver was always just named "Teradata", but to allow installing multiple TTU versions the name now includes the version:

 "Teradata Database ODBC Driver xx.yy"

 

A quick Google search for "VBA list odbc drivers" found the following suggestion, which uses WMI to search the registry and return an array of driver names.

You could then search the array for a name starting with "Teradata".

Const HKEY_LOCAL_MACHINE = &H80000002
Public Function GetODBCDriverNames()
    Dim strComputer As String, strKeyPath As String
    Dim objRegistry As Object, arrValueNames, arrValueTypes
    strComputer = "."
    strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
    Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
    GetODBCDriverNames = arrValueNames
End Function
1 ACCEPTED SOLUTION
2 REPLIES
Teradata Employee

Re: TD Driver Name in VBA connection string

A good question. In the past, the driver was always just named "Teradata", but to allow installing multiple TTU versions the name now includes the version:

 "Teradata Database ODBC Driver xx.yy"

 

A quick Google search for "VBA list odbc drivers" found the following suggestion, which uses WMI to search the registry and return an array of driver names.

You could then search the array for a name starting with "Teradata".

Const HKEY_LOCAL_MACHINE = &H80000002
Public Function GetODBCDriverNames()
    Dim strComputer As String, strKeyPath As String
    Dim objRegistry As Object, arrValueNames, arrValueTypes
    strComputer = "."
    strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
    Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
    GetODBCDriverNames = arrValueNames
End Function
Highlighted
Enthusiast

Re: TD Driver Name in VBA connection string

thank you so much.  This worked like a charm.