VB 6 data access depends on MsgBox

This problem is supernatural. I present it in the hope that someone may have seen it before and knows the fix.

VB6 environment, SQL 2005, Citrix XenApp 6.5. This behavior appears only when working with a Citrix client.

Context:

The main module is loading .bas and in the main section it calls SQL Server (2005) using ADO Recordsets to load data. When launched from the console, the application loads and displays after 1 or 2 seconds. When the Citrix client is called, it slows down for at least 30. However, if we place the MsgBox

i.e.

MsgBox "Test message ..."

in the Main sub code, it loads in 1-2 seconds just like loading from the console. The MsgBox should be placed after the MDI form has loaded, which acts as a visual background for the application. Placing it before loading the MDI does not fix the problem.

By placing debug messages in the MDI form header, we found that the time taken to traverse the recordset is where all the time is added.

The question is how does the MsgBox statement affect the access speed of the recordset. It sounds very strange, but with the expression MsgBox: fast, without it: deadly slow.

Below is a scaled down version of Sub Main with the magic MsgBox specified.

****************************************************************
*
****************************************************************
Sub Main()
On Error GoTo errHandler



'CSR 527
If Not ReadIniFiles Then
    MsgBox "Error reading ini files...contact systems.", vbExclamation
    End
End If

g_SecurityInClause = "YES"

If Not SetSecurity Then
    MsgBox "Unable to acquire your authorization credentials. Exiting..."
    Exit Sub
End If

Set cn = New Connection
With cn
 ' .ConnectionTimeout = 30
  .ConnectionString = CONNECTION_STRING
  .Open 'Options:=adAsyncConnect
End With

App.HelpFile = App.path & "\xx.chm"

g_bExiting = False

frmMain.MousePointer = vbHourglass
DoEvents
frmMain.Show

MsgBox "test"  <== PLACING THIS MSGBOX HERE SPEEDS UP APP BY A FACTOR OF AT LEAST 30
                   IF IT IS ABOVE frmMain.Show IT HAS NO EFFECT

'assign connection string and record source to ado controls
'PLOG 74

Load frmA


frmA.Adodc1.ConnectionString = CONNECTION_STRING
frmA.Adodc2.ConnectionString = CONNECTION_STRING
frmA.Adodc3.ConnectionString = CONNECTION_STRING

'timeouts for Phoenix
frmA.Adodc1.CommandTimeout = 300
frmA.Adodc2.CommandTimeout = 500
frmA.Adodc3.CommandTimeout = 500

frmA.Adodc1.RecordSource = "select some stuff"
frmA.Adodc2.RecordSource = "select some stuff"
frmA.Adodc3.RecordSource = "select some stuff"

frmA.Adodc1.Refresh
frmA.Adodc2.Refresh
frmA.Adodc3.Refresh

LoadMinorCodes
DetermineDeleteAccess
LoadStates

frmMain.MousePointer = vbNormal
frmStartBoard.Show


Exit Sub


errHandler:
MsgBox Err.Number & " " & Err.Description & " Main"


End Sub

      

+3


source to share


1 answer


From jac's comment, adding DoEvents and the fact that it worked for you, it must be a race-only issue. It was probably expected that the database would be connected before it showed the form. The addition of doEvents changed this order.



0


source







All Articles