Strange Behavior In OCX
At my work, we have a VB6 app that contains a custom OCX, also in VB6. Now, if these programs are compiled on one specific machine (running VB6 SP3, to give you an idea of how old this program is), everyone on the network can use it. If it's compiled on any other machine (such as my local machine running VB6 SP6) and then try to run it on another machine, the login screen will appear correctly, but as soon as you click OK to log in, the program ends. No error, no notification -- it just... stops.
My first thought is that maybe some of the DLLs are out of date on the other machines, but even manually updating all the dependencies to the same version from my local machine, the problem still persists.
I added MsgBox statements prior to every line in order to track down the last statement that attempts to execute before the program ends, and I tracked it down to a function in the OCX that is called to progress the login information. The function code is below, and the line it stops on is bolded.
What really wigs me out is that there is error checking code in the function, but the control never passes to the handler. I've tested this by adding a MsgBox immediately after the handler label, and it never displays.
So, in short... HELP!
--
My first thought is that maybe some of the DLLs are out of date on the other machines, but even manually updating all the dependencies to the same version from my local machine, the problem still persists.
I added MsgBox statements prior to every line in order to track down the last statement that attempts to execute before the program ends, and I tracked it down to a function in the OCX that is called to progress the login information. The function code is below, and the line it stops on is bolded.
What really wigs me out is that there is error checking code in the function, but the control never passes to the handler. I've tested this by adding a MsgBox immediately after the handler label, and it never displays.
So, in short... HELP!
--
Private Function ConnectToDatabase(ByVal pstrDBName As String, ByVal pstrUID As String, ByVal pstrPWord As String, cn As ADODB.connection)
On Error GoTo ConnectToDatabase_Err
Dim strConn As String
Dim AppName As String
Dim strMsg As String
Dim i As Integer
strConn = "Data Source=" & pstrDBName & ";User ID=" & pstrUID & ";Password=" & pstrPWord
Set cn = New ADODB.connection
With cn
.Provider = "MSDAORA"
.ConnectionString = strConn
.ConnectionTimeout = 100
.CursorLocation = adUseClient
.Open
End With
ConnectToDatabase = True
Exit Function
ConnectToDatabase_Err:
For i% = 0 To cn.Errors.Count - 1
If cn.Errors(i%).Number = -2147217843 Then
strMsg = "The User ID or Password is invalid. Please try again."
Exit For
Else
strMsg = "An error occurred while attempting to connect to the database. " _
& "Please write down the following error and contact IS support." _
& Chr(13) & Chr(13) & cn.Errors(i%).Number & ": " & cn.Errors(i%).Description
End If
Next i%
If strMsg$ = "" Then
Kato.DisplayError Err.Number, Err.Description, "ConnectToDatabase"
Else
MsgBox strMsg$, vbCritical, "Networx"
End If
ConnectToDatabase = False
Exit Function
End Function 