This content has been marked as final. Show 3 replies
I've concluded that the State property of a Connection object isn't reliable. The moment I added the test:
if( this.aConnection.State!=1 )
throw "The application cannot save your submission.";
we began to have problems with users of a our web app seeing the thrown message even though the database instance shows no evidence of connection trouble. I toyed with tracing OraOLEDB but never got that to work, and an Oracle support person suggested that type of tracing isn't reliable anyway. Finally, buried in some MS support document I saw the claim that a connection isn't actually opened until a recordset is returned.
That suggests that the real test for "connected" is whether your app can do the work you intend it to do: in other words, "try."
Can you please provide the link to the MS support document if possible?
The State property is a sort of enum so, strictly speaking, the test for !=1 is too simple.
The MS documentation for the Open method of the Connection object is here:
In a note they say:
"Remote Data Service Usage When used on a client-side Connection object, the Open method doesn't actually establish a connection to the server until a Recordset is opened on the Connection object."