|
|
|
Testing a DSN
5
Below is the code you can use in Access Database Forms, to test a DSN connection. Handy if you want to link some of your Forms to another database via DSN.
Private Sub Command0_Click()
Dim adoConn As ADODB.Connection
Dim adoRecSet As ADODB.Recordset
On Error GoTo ConnectError
Set adoConn = New ADODB.Connection
adoConn.Open "JustinDSN", "myuser", "mypass"
Exit Sub
ConnectError:
MsgBox "Could not connect to Server"
Exit Sub
If adoConn.State = 1 Then
MsgBox "Connection Successful"
Else
MsgBox "Connection Un-Successful"
End If
adoConn.Close
Set adoConn = Nothing
End Sub




There are currently no comments for this snippet.