2008-05-19 10:17:31 UTC
' Open Connection to the Database
Public Function OpenDBConnection() As Variant
On Error GoTo Error_Label
Dim strUserID As String ' User ID
Dim strPassword As String ' Password
strUserID = myid
strPassword = mypasw
' Get Database Connection
Set dbConnection = New ADODB.Connection
dbConnection.Open "DSN=DB214;UID=" + strUserID + ";PWD=" + strPassword
' Check if Connection is OPEN or CLOSED
If dbConnection.State = adStateClosed Then
MsgBox "Database Connection Closed", vbCritical, "DB Connection Error"
End If
Exit Function
Error_Label:
MsgBox "Cannot Connect To Database. Database Connection Failed", vbCritical, "DB Connection Error"
End Function