PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → HOpenConnection() doesn't work after few minutes
HOpenConnection() doesn't work after few minutes
Débuté par HIS 21, 04 oct. 2016 15:30 - 4 réponses
Membre enregistré
12 messages
Posté le 04 octobre 2016 - 15:30
Good evening everybody,

I have the following code in a "window". If I use it, for example, five time the code works fine but if I use this snippet of code one time, I wait for 5 or 10 minutes, and I try to re-use it, the application remain locked at HOpenConnection() call.

I have noticed that, on HFCC, the connections still remain visible in Connection tabs despite I closed them with HCloseConnection().

The code below is semplified, I use it to syncronize a remote HF database with the databese stored on the mobile device.

I hope I was clear and thank you in advance for answers.

remoteDatabaseConnection is Connection
remoteDatabaseConnection..Provider = hAccessHFClientServer
remoteDatabaseConnection..Access = hOReadWrite
remoteDatabaseConnection..Server = ggDBServer
remoteDatabaseConnection..Database = ggDBName
remoteDatabaseConnection..User = ggDBUser
remoteDatabaseConnection..Password = ggDBPassword


IF HChangeConnection(TABLE, remoteDatabaseConnection) THEN

IF HOpenConnection(remoteDatabaseConnection) THEN

HOpen(TABLE)

// something here

HClose(TABLE)

HCloseConnection(remoteDatabaseConnection)

HChangeConnection(TABLE, "")

HOpen(TABLE)
ELSE

Info("...")
END
ELSE

Info("...")
END
Posté le 04 octobre 2016 - 16:06
Hi

what mobile, what OS ?

Most mobile oS are putting the unused application to sleep after a fex
minutes, for battery purpose, so that may be your problem

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


Le 10/4/2016 à 7:30 AM, HIS 21 a écrit :
Good evening everybody,

I have the following code in a "window". If I use it, for example, five
time the code works fine but if I use this snippet of code one time, I
wait for 5 or 10 minutes, and I try to re-use it, the application remain
locked at HOpenConnection() call.

I have noticed that, on HFCC, the connections still remain visible in
Connection tabs despite I closed them with HCloseConnection().

The code below is semplified, I use it to syncronize a remote HF
database with the databese stored on the mobile device.

I hope I was clear and thank you in advance for answers.

remoteDatabaseConnection is Connection
remoteDatabaseConnection..Provider = hAccessHFClientServer
remoteDatabaseConnection..Access = hOReadWrite
remoteDatabaseConnection..Server = ggDBServer
remoteDatabaseConnection..Database = ggDBName
remoteDatabaseConnection..User = ggDBUser
remoteDatabaseConnection..Password = ggDBPassword


IF HChangeConnection(TABLE, remoteDatabaseConnection) THEN

IF HOpenConnection(remoteDatabaseConnection) THEN
HOpen(TABLE)

// something here

HClose(TABLE)

HCloseConnection(remoteDatabaseConnection)

HChangeConnection(TABLE, "")

HOpen(TABLE)
ELSE

Info("...")
END
ELSE

Info("...")
END
Membre enregistré
12 messages
Posté le 04 octobre 2016 - 16:46
Hi,

I'm working on Android 5.0.1 but it seems to be a problem not related to a specific version of Android (I've the same problem with earlier versions).

I've noticed that if I close my application (with the Android application manager) the problem disappear until I repeat the action that I've explained in the initial post.

Have you an idea about waht could be causing the problem?
Posté le 04 octobre 2016 - 20:09
> Have you an idea about waht could be causing the problem?

yes... exactlywhat I described...

If the application doesn't do anything, android is going to put it to
sleep to save battery life...

And it seems that it also means blocking/cutting the connection
Membre enregistré
12 messages
Posté le 05 octobre 2016 - 16:46
Thanks a lot for your answers.

The behavior you have described wasn't the problem, the connection was not working even if the application didn't goes in background.

I've solved by calling HCangeConnection() function only once time instead of many time on each execution the application.

I've put the HCangeConnection() function in the project code and the HOpenConnection() and HCloseConnection() every time I need to connect to the remote database.

After these changes all works fine.