Re: [D7 Ent] [TADOStoredProc] lose and get back network connexion it still raise exceptionl
- From: "Steve Zimmelman" <skz@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 27 Jan 2006 12:00:38 -0500
When a connection is severed in the manner you described, the connection is
broken and must be reestablished with the server. You cannot simply "put
the cable back in", and have it pickup where you left off.
You should be able to close the AdoConnection and then reopen it. The
AdoConnection does not set its Connected property to False when the
connection is severed. You must manually do that to reconnect.
_Cmd.Connected := False or _Cmd.Close
_Cmd.Connected := True or _Cmd.Open
You should also be aware that if a connection sits without activity, you
stand a chance of loosing the connection. SQL Server (depending how it is
setup) will drop inactive connections. We have had this happen and have
taken steps to prevent it by creating our own subclass of TAdoConnection.
http://groups.google.com/group/borland.public.delphi.database.ado/browse_thread/thread/712d08687d5bf160/2017b8c9ee522132?lnk=st&q=MS+SQL+%22Connection+Failure%22+Possible+Solution+group%3Aborland.public.delphi.*&rnum=1&hl=en#2017b8c9ee522132
Regards,
-Steve-
"aaa.aaaa" <aaa.aaa@xxxxxxx> wrote in message
news:43da441d$1@xxxxxxxxxxxxxxxxxxxxxxxxx
> Hi All,
>
> I have a problem with TADOStoredProc
> If I lose the network the system raise an exception, (General Network
> Error) It is ok !!
>
> But when i get back the network connexion, the system still raise an
> exception (Connexion failure).
>
> The TADOConnection is created only the first time (singleton)
>
> my procedure to test it :
>
> 1- I execute the test one time with network ; Result OK
> 2- I unplug my network cable , run the test ; Result = General Network
> Error exception OK
> 3- I plug back the cable, run the test ; Result = Connection Failure
> exception ; WHY ?
>
> If I create the TADOConnection each time it works fine, but i don't want
> to do that !!!
>
> If i use an proc stock with params, the system raise exception because is
> cannot find the params when i get back the network ?
>
>
> How can i fix that ?
> I don't want to close the application each time the system lose and get
> back the network connexion
>
> With TADOQuery is working fine !!
>
> Thanks !!!
>
>
>
> See under my code source
>
> Unit ADONetworkTest
> .......
> type
> TCnxFailureTests = class(TTestCase)
> private
> protected
> published
> // Test methods
> procedure TestFailureCnxStoredProcWithoutParams2;
>
> end;
>
> implementation
>
> var
> _Cmd:TADOConnection;
>
> function GetCmd: TADOConnection;
> begin
> if _Cmd = nil then
> begin
> _Cmd:= TADOConnection.Create(Nil);
> _Cmd.ConnectionString:= 'Provider=SQLOLEDB.1;Persist Security'
> + 'Info=True;User ID=sa;Initial Catalog=Northwind;'
> + 'Data Source=MYSERVER\DEV';
> _Cmd.LoginPrompt:= False;
> end;
> Result:= _Cmd;
> end;
>
>
> procedure TCnxFailureTests.TestFailureCnxStoredProcWithoutParams2;
> var
> _SP: TADOStoredProc;
> begin
>
> _SP:= TADOStoredProc.Create(Nil);
> try
> _SP.Connection:= GetCmd;
> _SP.ProcedureName := 'dbo.SP_TEST';
> _SP.ExecProc;
> Check(_SP.Connection.Connected , 'Error Falure Cnx');
> finally
> FreeAndNil(_SP);
> end;
>
> end;
.
- References:
- Prev by Date: [D7 Ent] [TADOStoredProc] lose and get back network connexion it still raise exceptionl
- Next by Date: Re: Integer array as BLOB
- Previous by thread: [D7 Ent] [TADOStoredProc] lose and get back network connexion it still raise exceptionl
- Index(es):
Relevant Pages
|