How do I reopen lost connection?

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
zd
Posts: 78
Joined: Sun 01 Jul 2007 13:16

How do I reopen lost connection?

Post by zd » Thu 02 Oct 2008 16:18

Okay, I can't seem to figure this out.

I'm connected to the database, I have a bunch of events registered in my app.
I stop Firebird using the control panel applet.
I get the "unknown ISC error 0" messages (thanks for the fix, btw)
Then I display a dialog that would allow my users to reconnect to the database.

I restore the connection in my test manually (using the control panel applet), then I make my program call IBCConnection.Connect, then I run a custom query. (IBCQuery.Open)

The result:
"Error writing data to connection" message.

I've tried disconnecting then reconnecting but with no luck. If I create a new TIBCConnection object it can connect, but the old one can't seem to connect again.

How do I reconnect once the connection has been cut off then restored to the server?

Thanks!

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 03 Oct 2008 12:58

You should call the Disconnect method before calling Connect.

zd
Posts: 78
Joined: Sun 01 Jul 2007 13:16

Post by zd » Fri 03 Oct 2008 14:37

If I call disconnect before connect, it raises an "Error writing data to connection" message!

If I stop the firebird server
handle the unknown isc error 0 error in my program
relaunch the firebird server
call connect
then the "Error writing data to connection" message comes when I want to execute a query.

If I call disconnect (after relaunching the server), I get the "Error writing data to connection" message instantly, and after that, I call connect, and when executing a query, I get "can't perform operation on inactive transaction message".

What should I do to solve the problem?

Thanks!

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 07 Oct 2008 07:26

We could not reproduce the problem. Please send to ibdac*devart*com a complete small sample that demonstrates the problem.

zd
Posts: 78
Joined: Sun 01 Jul 2007 13:16

Post by zd » Wed 08 Oct 2008 08:55

Sample program sent.

zd
Posts: 78
Joined: Sun 01 Jul 2007 13:16

Post by zd » Fri 10 Oct 2008 14:24

Hi!

Have you managed to find the source of the problem?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 13 Oct 2008 11:32

We cannot reproduce the problem with your sample. Maybe it can help if you call Disconnect in try..except block.

zd
Posts: 78
Joined: Sun 01 Jul 2007 13:16

Post by zd » Mon 13 Oct 2008 20:11

No it doesn't help.
I'm getting the "Error writing data to connection" message if I put disconnect in a try/except block.

I've sent you the same example but with a compiled executable.

Please launch the executable to reproduce the error.

Please let me know when you have something!

Thank you!

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 14 Oct 2008 13:22

I have reproduced the problem with your last sample. I could not find the difference between two samples but when I recompile the last sample I can reproduce the problem, and with the previous sample I cannot.

When I modify your sample in the following way, no error message is shown:

Code: Select all

  try
    IBCConnection1.Disconnect;
  except
    on EIBCError do ;
  end;
    IBCConnection1.Connect;
 
    IBCQuery1.SQL.Text:='SELECT * FROM Test';
    IBCQuery1.Open;

zd
Posts: 78
Joined: Sun 01 Jul 2007 13:16

Post by zd » Wed 15 Oct 2008 09:31

Hi Plash!

You're right that the try/except block solves the problem in the example I sent you, but not in my main application, based on which I made the example!

In my main application where I experienced the error first, if I try to put the disconnect call in a try/except block the exception is handled and IBCConnection manages to reconnect.

But upon executing a query I'm getting the 'Can't perform operation on inactive transaction' error message, no matter what I do.

On the other hand, if I put a second connection component on the form and use that for reconnecting, no error occurs!

Thus, I'm supposing that there is something changed in IBCConnection's state after a forced disconnect, which won't let you reconnect normally.

If you have any ideas on what might be causing this part of the problem please let me know.

Otherwise I'll try to make another example later today to reproduce the new problem!

Thank you!

zd
Posts: 78
Joined: Sun 01 Jul 2007 13:16

Post by zd » Thu 16 Oct 2008 07:51

Dear Plash,

I've sent you a new example which demonstrates the problem further. Please check it out.

Thank you!

Post Reply