PDA

Click to See Complete Forum and Search --> : DataSource Name at Runtime


benpartlow
Apr 13th, 2000, 08:15 PM
Is there an object that allows the user to select an available ODBC datasource at run time from available data sources on the PC? I imagine it would behave in the same manner as the drop down box in the MSRDC data source property window at design time. This feature (I don't know how) lists datasources available on the PC

Thank you in advance.

Clunietp
Apr 13th, 2000, 09:49 PM
'uses ODBC DRIVER & DATA SOURCE NAME FUNCTIONS library
'this will list all DSNs and ODBC drivers installed
'on the current machine

Dim objDSN As Dsn
Dim lngCounter As Long

Set objDSN = New Dsn

Dim strDSNArray() As String
Dim strDriverArray() As String

'==============================================================
'GET DSN LISTING
'==============================================================
objDSN.GetDataSourceList strDSNArray

Debug.Print "-------------------DSNs--------------------------"
For lngCounter = LBound(strDSNArray()) To UBound(strDSNArray())
Debug.Print strDSNArray(lngCounter)
Next lngCounter
'==============================================================
'GET ODBC DRIVER LISTING
'==============================================================
objDSN.GetOdbcDriverList strDriverArray()

Debug.Print "---------------ODBC Drivers----------------------"
For lngCounter = LBound(strDriverArray()) To UBound(strDriverArray())
Debug.Print strDriverArray(lngCounter)
Next lngCounter
'==============================================================
'cleanup
Set objDSN = Nothing


HTH

Tom