Question Database Access... A 'Timeout' Problem?

JoeFX

Member
Joined
Mar 18, 2009
Messages
6
Programming Experience
3-5
Hi

Not sure if I'm in the right forum here because I'm not entirely sure if the problem I've got is with my database, or webserver config or something else...

Basically I've got a question about accessing a MySQL database. Before I give the question though, this is what I'm doing (or trying to do)...

I'm putting together a website for a local football league which allows people to view the latest results and stats, all stored in a database. At the moment I've got a MySQL database on my webserver, which is very simple and only contains two tables - one table for the teams, and another for the matches (dates, venue, result etc).

At the moment I've created a simple page which, on first-load, will query the database and get a list of all the teams. The teams are then added to two combo-boxes on the web page. Next to the combo-boxes I've got a 'Get Results' button - when the user chooses a team from each combobox and clicks the 'Get Results' button, I run another query which returns all matches where 'Team A' has played 'Team B' - the details of that query are displayed in a web table on the same page.

Now, I've got this working fine so far... however, I've got one problem which I can't figure out. What I'm finding is that if I open up the web page, run a query (i.e. click the Get Results button), and then leave the webpage unattended for a five minutes. If I try to run another query, I'm getting an unhandled exception somewhere. The real error isn't being displayed on-screen (even though I'm running with debugging enabled), all I'm getting is this...

"Server Error in '/' Application.
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code."

I'm guessing that something somewhere is 'timing out', because I can run query after query with no problems, it's only if I leave the web page open for a while (without touching anything) that this problem comes up.

If I run this web page locally (in the dev environment) and connect to the same database remotely (i.e. via an IP instead of 'localhost') then I don't see this problem at all. I'm only getting it when I upload the site to my web server.

I've tried all kind of different ways of accessing the database, but all of them result in the same timeout error. At the moment, when I run a query I'm doing something like this...
VB.NET:
Dim myConnection As MySqlConnection = New MySqlConnection("server=localhost;user id=xxxx;password=xxxx;pooling=false;")
Dim myDataAdapter As MySqlDataAdapter
Dim myDataSet As DataSet
myDataAdapter = New MySqlDataAdapter("Select * from Teams", myConnection)
myDataSet = New DataSet()
myDataAdapter.Fill(myDataSet, "Teams")

' read the data from myDataSet and draw the web table for any rows that are returned

myConnection.Close

I can't figure out why that bit of code will work fine, but after 'x minutes' of inactivity it suddenly throws an exception when called again.

Am I missing some sort of Keep Alive value or something somewhere, be it in my code or perhaps a setting on my webserver?

Also, it would help a lot if I can see what the actual error is (i.e. which line of code is throwing the exception), but I'm only getting that aforementioned generic error. Is there any way to capture the real error (bearing in mind that I've already got debugging enabled).

Thanks!
 
Back
Top