Subject Disconnect Troubles
Author Paul Irwin
I got it to work, sort of anyway. It seems to behave differently depending
upon the following 2 scenarios.

1. Connect to database.
2. Execute a Stored Procedure
3. Physically disconnect (i.e. unplug network cable)
4. Execute a Stored Procedure
5. Trap the error
6. Rollback all transactions
7. Disconnect
8. Physically reconnect
9. Connect

This works fine. The following scenario does not work...

1. Connect to database.
2. Physically disconnect (i.e. unplug network cable)
3. Execute a Stored Procedure
4. Trap the error
5. Rollback all transactions
6. Disconnect

For some reason the Disconnect causes another error. It also results in
numerous access violations and such when the program is closed. The only
difference is that the physical disconnection occured before executing a
stored procedure. If this is intentional behavior than I can deal with it,
but it doesn't seem that this is how it should behave. I use CBuilder 5 and
I'm not familiar with Delphi so looking at the source code is not much of an
option for me at this point.

Any suggestions, work arounds or settings that might fix this would be
greatly appreciated.

Thanks,

Paul


> -----Original Message-----
> From: Jason Wharton [mailto:jwharton@...]
> Sent: Monday, June 11, 2001 12:59 PM
> To: IBObjects@yahoogroups.com
> Subject: Re: [IBO] Disconnect Troubles
>
>
> You need to rollback all transactions and disconnect the database and then
> attempt to connect again.
>
> Jason Wharton
> CPS - Mesa AZ
> http://www.ibobjects.com
>
>
> ----- Original Message -----
> From: "Paul Irwin" <paul@...>
> To: <IBObjects@yahoogroups.com>
> Sent: Monday, June 11, 2001 12:47 PM
> Subject: [IBO] Disconnect Troubles
>
>
> > Hmm... let me try to rephrase it, disregarding the code sample from
> before.
> > I trap the error and post a message to the main form. How can I attempt
> to
> > reconnect. The connection status of the TIB_Connection remains as
> > csConnected after the error. If I do Connect(), nothing happens because
> it
> > thinks it's still connected. If I do Disconnect(), I get another error
> and
> > the connection status remains csConnected. How can I make the
> > TIB_Connection component realize that it is not connected and
> force it to
> > try to reconnect?
> >
> > > -----Original Message-----
> > > From: Jason Wharton [mailto:jwharton@...]
> > > Sent: Monday, June 11, 2001 11:45 AM
> > > To: IBObjects@yahoogroups.com
> > > Subject: Re: [IBO] Disconnect Troubles
> > >
> > >
> > > This looks to me like you could be asking for an infinit loop.
> > >
> > > It generally isn't a good idea to perform actually connect and
> disconnect
> > > operations in an error handler. it is better to set some flags
> > > and then have
> > > the operations be performed in some independent fashion.
> > >
> > > For example, you would flash a message to the user that the connection
> has
> > > been lost and what they should do. Then, after the exception is
> > > handled they
> > > would go and do whatever it was they needed to.
> > >
> > > HTH,
> > > Jason Wharton
> > > CPS - Mesa AZ
> > > http://www.ibobjects.com
> > >
> > >
> > > ----- Original Message -----
> > > From: "Paul Irwin" <paul@...>
> > > To: <IBObjects@yahoogroups.com>
> > > Sent: Monday, June 11, 2001 11:34 AM
> > > Subject: [IBO] Disconnect Troubles
> > >
> > >
> > > > I'm trying to handle the situation where I loose a connection to the
> > > > database. In the OnError event of the TIB_Connection I have
> > > the following
> > > > code:
> > > >
> > > > if (ERRCODE == 335544721 && IB_Con->ConnectionStatus !=
> > > csDisconnectPending)
> > > > {
> > > > IB_Con->Disconnect();
> > > > IB_Con->Connect();
> > > > }
> > > >
> > > > I realize there needs to be more code to handle if it cannot connect
> > > > again... but this is just some test code. The problem is that
> > > Disconnect
> > > > generates another error and the connectionstatus gets reset to
> > > connected.
> > > >
> > > > How or what is the best way to handle this. I want to
> prompt the user
> > > with
> > > > a message that the connection has been lost and allow them
> to attempt
> to
> > > > reconnect.
> > > >
> > > > Thanks,
> > > >
> > > > Paul
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Your use of Yahoo! Groups is subject to
> > > http://docs.yahoo.com/info/terms/
> > > >
> > > >
> > >
> > >
> > >
> > >
> > > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> > >
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> >
> >
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>