[quoted text, click to view] "Phil Smith" wrote:
<snip>
[quoted text, click to view] > Our site was reporting errors which were attributed
> to loss of client connection to the server.
<snip>
[quoted text, click to view] > we think what is happening is that ADO is just
> creating additional connections
<snip>
Phil,
As has already been pointed out, "hidden" connections can be created behind
your back. The most common situation I know of with ADO is opening multiple
recordsets on a connection object: if there's an open recordset on a
connection, opening a second recordset creates a hidden connection behind
the scenes.
As for strange connection failures: we've observed one situation with ADO
like this... if the physical Ethernet link is broken and then some kind of
network operation on the Connection object is requested, an error will be
thrown, the Connection's State property will still be adStateOpen, and any
attempt to use the Connection object will fail. Even after the physical
link is re-established, the connection object will no longer work (even
though the State property shows it as open).
We found this out because one of our main Ethernet switches was not on a UPS
and on a outlet not connected to the backup generator and main UPS (I know,
I know, don't get me started). In any event, when that switch lost and
regained power, anyone connected to the switch with an ADO connection was
broken (assuming they'd been doing anything). We were able to reproduce
this for testing purposes by opening a connection, removing the Ethernet
cable on a computer, issuing a simple select on the Connection object, and
then re-connecting the Ethernet cable.
Our applications use a wrapper class around the ADO connection, so our
solution was to detect this particular state when a database operation
raised an error. If we found the state had occurred, we would save the
connection string, close the connection, destroy it, create a new
connection, and open the new connection with the same connection string. I'm
leaving out retry logic and our application-level transaction tracking, but
you get the idea...
Here's the VB 6 code we used for detecting this (editing in my news editor,
so not guaranteed to be syntax error free):
Private Function LinkFail(ByVal conn As Connection) As Boolean
Dim e As ADODB.Error
Dim bLinkFail As Boolean
If conn Is Nothing Then
bLinkFail = False
ElseIf conn.State <> adStateOpen Then
bLinkFail = False
Else
For Each e In conn.Errors
'Not the cleanest thing in the world, but it works
If Trim$(UCase$(e.SQLState)) = "08S01" Then
bLinkFail = True
Exit For
End If
Next e
End If
LinkFail = bLinkFail
End Function
Craig