Dark Sand
May 5th, 2003, 09:25 AM
I’ve been using a VB component that uses an API to connect to a database and it’s been working fine so far. However we’ve recently upgraded the API to use an asynchronous connection instead of the synchronous connection we were using before, and while it still works fine in VB, ASP is no longer able to connect with the DB.
The API uses the standard message loop to listen for the reply from the database and process the connection (The t.t command is for output to a log file.)
Public Sub SpinOlehWnd(ByVal Hwnd As Long, ByVal fYield As Boolean, ByRef t As CTraceFile)
Dim PMFlags As PMOptions
Dim wMsgMin As Long
Dim wMsgMax As Long
Dim MSG As MSG
If fYield Then
PMFlags = PM_REMOVE
Else
PMFlags = PM_REMOVE Or PM_NOYIELD
End If
If Hwnd = 0 Then
'Not sure which window to spin on (this is very unlikely)
'A PeekMessage loop on all windows can still beat DoEvents
'and reduce side effects by just looking at WM_USER messages
'and higher
wMsgMin = &H400 'WM_USER
wMsgMax = &H7FFF
End If
Do While PeekMessage(MSG, Hwnd, wMsgMin, wMsgMax, PMFlags)
TranslateMessage MSG 'Probably does nothing, but technically correct
t.t "SpinOlehWnd MSG.Message=", CStr(MSG.Message)
t.t "SpinOlehWnd MSG.WPARAM=", CStr(MSG.WPARAM)
t.t "SpinOlehWnd MSG.LPARAM=", CStr(MSG.LPARAM)
t.t "SpinOlehWnd MSG.dwTIME=", CStr(MSG.dwTime)
t.t "SpinOlehWnd DispatchMessage returned ", CStr(DispatchMessage(MSG))
Loop
End Sub
I know from looking at the log file that the API receives a reply from the server and sends it off to be processed, but after that it seems to disappear. The event that’s fired when the DB server’s reply is processed never goes off in ASP and the component just sits there doing nothing.
I think that what’s happening is that somehow DefWindowProc() is throwing out the reply, but so far I haven’t been able to confirm if that’s the case. I know for a fact that this code works perfectly when used in VB, the problem only happens in ASP.
If anyone knows what might be causing the problem and might have an idea how to fix it I would greatly appreciate your help.
Thank you.
P.S. I know this might be be the right forum for this, but I'm not exactly sure where it should go.
The API uses the standard message loop to listen for the reply from the database and process the connection (The t.t command is for output to a log file.)
Public Sub SpinOlehWnd(ByVal Hwnd As Long, ByVal fYield As Boolean, ByRef t As CTraceFile)
Dim PMFlags As PMOptions
Dim wMsgMin As Long
Dim wMsgMax As Long
Dim MSG As MSG
If fYield Then
PMFlags = PM_REMOVE
Else
PMFlags = PM_REMOVE Or PM_NOYIELD
End If
If Hwnd = 0 Then
'Not sure which window to spin on (this is very unlikely)
'A PeekMessage loop on all windows can still beat DoEvents
'and reduce side effects by just looking at WM_USER messages
'and higher
wMsgMin = &H400 'WM_USER
wMsgMax = &H7FFF
End If
Do While PeekMessage(MSG, Hwnd, wMsgMin, wMsgMax, PMFlags)
TranslateMessage MSG 'Probably does nothing, but technically correct
t.t "SpinOlehWnd MSG.Message=", CStr(MSG.Message)
t.t "SpinOlehWnd MSG.WPARAM=", CStr(MSG.WPARAM)
t.t "SpinOlehWnd MSG.LPARAM=", CStr(MSG.LPARAM)
t.t "SpinOlehWnd MSG.dwTIME=", CStr(MSG.dwTime)
t.t "SpinOlehWnd DispatchMessage returned ", CStr(DispatchMessage(MSG))
Loop
End Sub
I know from looking at the log file that the API receives a reply from the server and sends it off to be processed, but after that it seems to disappear. The event that’s fired when the DB server’s reply is processed never goes off in ASP and the component just sits there doing nothing.
I think that what’s happening is that somehow DefWindowProc() is throwing out the reply, but so far I haven’t been able to confirm if that’s the case. I know for a fact that this code works perfectly when used in VB, the problem only happens in ASP.
If anyone knows what might be causing the problem and might have an idea how to fix it I would greatly appreciate your help.
Thank you.
P.S. I know this might be be the right forum for this, but I'm not exactly sure where it should go.