N
Nick Stansbury
SUMMARY - Closing a connection, or getting a parameter's value in an event
handler for executecomplete in an ado connection causes an irrecoverable
crash and corruption of ms access & the vba modules / code.
Hi,
Apologies for posting to three groups - not sure where this one fits. I
have discovered (and suffered all day with) a really really irratating ado
bug - it causes access / vba to crash completely, and corrupts the access db
/ vba modules so that they become unusable. I've got it pretty well nailed
down and wonder whether anyone can help!
I have been dealing with a series of long running queries against a sql
server on the other side of the world that I wanted to execute
asynchronously (but consequtively). No problems in getting them to execute -
but I also wanted to abstract the connection management (i.e. it started by
opening the connection, fired off the async commands - and then an event
handler for executecomplete read the output parameters into a collection and
closed the conection).
Either reading the value of a parameter in this event handler or closing
the connection leads to a crash - not when the line executes but in the
"non-vb code" section immediately afterwards. Even if I put a breakpoint on
the line of code in question and then try and "stop" execution rather than
let it carry on the crash happens anyway. Doing either of these things
causes the crash.
Please can anyone help! I'm pretty desparate as I don't want to have to drop
this feature - it'd be such a pain to do it synchronously.!
Thanks in advance
Nick
So here's some simplified code:
Private Sub MyConnection_ExecuteComplete( _
ByVal RecordsAffected As Long, _
ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, _
ByVal pCommand As ADODB.Command, _
ByVal pRecordset As ADODB.Recordset, _
ByVal pConnection As ADODB.Connection)
dim cmd as adodb.command, param as adodb.parameter
for each cmd in me.ExecutingCommands
if cmd is pCommand then
'parse the output parameters into a collection i.e.
for each Param in pCommand.Parameters
OutputParameters.add Param.Name, Param.value '<-- This
line will cause the crash
Next
if IndexOf(cmd, ExecutingCommands) = ExecutingCommands.Count
then
'this is the last command in the seriea
pConnection.close '<-- As will this line here
raiseevent ExecutionComplete
end if
end if
Next
End Sub
handler for executecomplete in an ado connection causes an irrecoverable
crash and corruption of ms access & the vba modules / code.
Hi,
Apologies for posting to three groups - not sure where this one fits. I
have discovered (and suffered all day with) a really really irratating ado
bug - it causes access / vba to crash completely, and corrupts the access db
/ vba modules so that they become unusable. I've got it pretty well nailed
down and wonder whether anyone can help!
I have been dealing with a series of long running queries against a sql
server on the other side of the world that I wanted to execute
asynchronously (but consequtively). No problems in getting them to execute -
but I also wanted to abstract the connection management (i.e. it started by
opening the connection, fired off the async commands - and then an event
handler for executecomplete read the output parameters into a collection and
closed the conection).
Either reading the value of a parameter in this event handler or closing
the connection leads to a crash - not when the line executes but in the
"non-vb code" section immediately afterwards. Even if I put a breakpoint on
the line of code in question and then try and "stop" execution rather than
let it carry on the crash happens anyway. Doing either of these things
causes the crash.
Please can anyone help! I'm pretty desparate as I don't want to have to drop
this feature - it'd be such a pain to do it synchronously.!
Thanks in advance
Nick
So here's some simplified code:
Private Sub MyConnection_ExecuteComplete( _
ByVal RecordsAffected As Long, _
ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, _
ByVal pCommand As ADODB.Command, _
ByVal pRecordset As ADODB.Recordset, _
ByVal pConnection As ADODB.Connection)
dim cmd as adodb.command, param as adodb.parameter
for each cmd in me.ExecutingCommands
if cmd is pCommand then
'parse the output parameters into a collection i.e.
for each Param in pCommand.Parameters
OutputParameters.add Param.Name, Param.value '<-- This
line will cause the crash
Next
if IndexOf(cmd, ExecutingCommands) = ExecutingCommands.Count
then
'this is the last command in the seriea
pConnection.close '<-- As will this line here
raiseevent ExecutionComplete
end if
end if
Next
End Sub