views:

71

answers:

1

Hi,

I have some ASP (Classic) code that queries a SQL 2005 Express database. I'm currently handling programmatically if this DB goes down by handling the error when someone tries to connect and can't. I capture the error and bypass subsequent db queries to this database using a session variable.

My problem is that this first query takes about 20 seconds before it timeouts.

I'd like to reduce this timeout length but can't find which property either in the code or database is the right one to reduce.

I've tried following in the code;

con.CommandTimeout = 5

con.CONNECTIONTIMEOUT = 5

Any suggestions please?

Thanks,

Andy

A: 

First off you should investigate why the DB is going down at all. We manage servers for hundreds of clients and have never run into a problem with the DB going down unless it was scheduled maintenance.

Besides that, you're already onto the right properties.

"Connect Timeout" is set in the connection string and controls how long the client waits to establish a connection to the database. It should be safe to lower this value in most cases--connections should never take long to establish.

"CommandTimeout" is a property on the IDbCommand implementation and controls how long the client waits for a particular query to return. You can lower this value if you know your queries will not take longer than the value you're setting.

Sam
hi, yes it's really only to handle issues when the server is down for things like maintenance.Setting con.ConnectionTimeout = 3 for example doesn't seem to have any effect, it still takes 20s before times out.
Andy Davies