View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
wpiet wpiet is offline
external usenet poster
 
Posts: 23
Default If ODBC DSN connection fails

I found what I need, thanks to Walter Wang. It's in the 6th post at this link:

http://www.microsoft.com/communities...&cr=&sloc=&p=1

Thanks to you & to Peter for your efforts.
--
Will


" wrote:

Sorry. I couldn't get it.

This is as far as I got.

I can't figure out how to tell if you have a valid ADODB
connection ....


Sub t()
Dim cb As Boolean
cb = TestConnect("bobnet", "bobnet2005")
End Sub

Function TestConnect(username As String, password As String) As
Boolean
Dim m_connection As ADODB.Connection
Dim dbsource As String
dbsource = "Provider=IBMDADB2.1;Data
Source=SOMESCHEMA;Location=somemachine:9100"
username = "someusername"
password = "somepassword"
Set m_connection = CreateObject("ADODB.Connection")
m_connection.CommandTimeout = 2000
m_connection.Open dbsource, username, password
For Each proLoop In m_connection.Properties
MsgBox proLoop.Name & " " & proLoop.Attributes
Next proLoop
m_connection.Close
TestConnect = True
End Function