1. Berka Frenfert
  2. PowerBuilder
  3. Wednesday, 1 February 2023 13:40 PM UTC

I connect to SQLServer with ODBC 18 in login window.

I retrieve a report that takes long time.

I terminate connection from server side.

I get message on the client side that communication link is broken.

I wrote code for the retrieve button so that it should check connection every time. So to check communication the simplest idea that came to my mind was Connect statement that runs every time retrieve button is clicked.

I click on retrieve button and i get message that Transaction already connected but that is okay and retrieve starts.

I terminate session from server side while retrieve was in progress  and my app shows message communication link failure and retrieve is stopped. That is also okay.

I click on retrieve button again but this time as i know connection is broken already so Connect statement should return me zero because there is no connection. But i get negative SQLCODE -1 which as i believe is wrong. I expect that Connect statement will return zero and connection will be made again but that does not happen.
So i think transaction object SQLCA has no clue when the connection was broken or if it had the information then transaction object is not setting some flag that indicate broken link.

I don't know how it showed me communication link failure while my attempt to reconnect with Connect statement never succeeded after i terminated the process on server side.

I close application and restart it and then open report and retrieve it then it works fine. The problem with this process is that the login has to do every thing that is required for connection. But I want to reconnect with DB on retrieve button instead of opening login window again. The problem i think is that if transaction object is not destroyed after communication link failure then Connect statement does not work properly.

So first thing how do i know there is communication link failure while connect statement always return -1 on retrieve button? (login window issued 1st run of Connect; )


So what you might suggest me to look into or do to get transaction object back online again with connect  statement?

Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 1 February 2023 14:00 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi.

First of all I would check contents of SQLDBCode & SQLErrText. Maybe there you will find come explanation.

Instead of running Connect statement, I would execute a simple command (like: select 1) and see the sqlcode returned. If -1 then I would execute connect statement. Although I n ever tested that.

Andreas.

Comment
  1. Andreas Mykonios
  2. Wednesday, 1 February 2023 14:35 PM UTC
It isn't. And I'm not sure but connect statement may require more resources.

Andreas.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 1 February 2023 14:40 PM UTC
Hi Andreas,

Indeed you are very right: Maybe they should change "if your ARE connected" into "if you have been at least once connected".

regards.
  1. Helpful 1
  1. Berka Frenfert
  2. Wednesday, 1 February 2023 14:44 PM UTC
for SQLSERVER Select TOP 1 can work but i haven't checked it. One of My table always have 1 row in it
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.