[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Losing connectiion to mySql db after small period of inactivity

Posted on 2004-10-22
12
Medium Priority
?
187 Views
Last Modified: 2010-05-02
Hi all,
I'm losing connection to a mySql database on the WAN after a period of inactivity (only a few minutes).
I get a "Lost connection" error when I do a rst.update (funny thing, if I do it 2 more times, it seems to re-connect by itself and rst.update works, which is good because all the recordset info is intact when it re-connects by itself).
The question is: is there a way or command to make it re-connect without having to to rst.update 2 more times?
Better yet, how can I make it so that it won't loose connection after any period of inactivity?
(btw, in previous solutions cn.connectiontimeout was recommended. this is not correct).
thanks
phil
0
Comment
Question by:spoowiz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12382288
>Better yet, how can I make it so that it won't loose connection after any period of inactivity?
A connection timeout parameter could be configured in the mySQL server.
Or you can make a "keep alive" function by making dummy queries every minute using a timer.
0
 

Author Comment

by:spoowiz
ID: 12382348
tell me more, please, about the "dummy timer", thanks
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 1000 total points
ID: 12382461
You have to create a timer somewhere in your code.

Here is some demo code:

Dim StartTime As Date

Private Sub KeepAliveBtn_Click()
    Timer1.Interval = 60000     ' produces an event every minute
    Timer1.Enabled = True
    StartTime = Now
    Me.Caption = StartTime
End Sub

Private Sub Timer1_Timer()
     ' Put an dummy sql query here. Something like "SELECT 1"
End Sub
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12382589
Forgot to mention, Timer1 is a timer object you must to insert into your form.
0
 

Author Comment

by:spoowiz
ID: 12382600
Looks promising. Learning something new...
What would happen when the interval time arrives and the program is doing something? Does it have potential to interrup the going process and cause a problem?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12382621
I don't think so, timer function is made in parallel with your process, mySQL support multiple queries from the same source.
0
 

Author Comment

by:spoowiz
ID: 12382681
thanks
0
 

Author Comment

by:spoowiz
ID: 12382706
jaime - where can i find the timer object?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12382913
Timer is a standard ActiveX control which icon is a little clock. You have to drag it to your form.
Have a look to this:
http://sunsite.iisc.ernet.in/virlib/html/platinum/f50-19.gif
0
 

Author Comment

by:spoowiz
ID: 12382988
I'm using VB6. I don't see it under "Components". (Your screen says "additional controls" at top, mine doesn't). How do I get to your screen?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12383572
Sorry, I have grabbed from the Internet because I haven't installed VB in my office machine.

I have gone to another computer to take a screenshot. Have a look to:
http://www.micrologicaperu.com/vbtimer.html

As you can see, Timer is a standard (fundamental) control you can find in your control toolbar in VB, if not, just have to search and installl in components dialog.
Select it and "draw" it in your form, then double click to generate a Timer event, and fill it with a dummy query.
0
 

Author Comment

by:spoowiz
ID: 12383605
thanks again. i didn't realize it was a standard one.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question