Sub CommandButton2_Click() Dim cnn As ADODB.Connection Set cnn = New ADODB.Connection ' Open a Connection using an ODBC DSN named "Pubs". cnn.Open "ss_program_workflow", "webuser", "zwebuserprd" ' Find out if the attempt to connect worked. If cnn.State = adStateOpen Then MsgBox "Welcome to Pubs!" Else MsgBox "Sorry. No Pubs today." End If ' Close the connection. cnn.Close End Sub
From novice to tech pro — start learning today.