How to solve TimeOut Expired Problem?

Gopal picture Gopal · Oct 13, 2009 · Viewed 48.6k times · Source

Using SQL Server 2005 and VB6

When I executing for yearly data or more than 3 months' data, it is showing "Timeout Expired" error. It is not executing completely.

My Connection String

ConnectionString = "Provider=SQLOLEDB.1;" & _
    "Persist Security Info=False; " & _
    "User ID=" & Settings.SQL_Username & _
    "; Password = " & Settings.SQL_Password & "; " & _
    "Initial Catalog=" & Settings.SQL_DatabaseName & ";" & _
    "Data Source=" & Settings.SQL_ServerAddress

How do I solve this problem?

Plz...

Answer

marc_s picture marc_s · Oct 13, 2009

There's no "black voodoo magic" out there - either you can make your query go faster (return less data, improve the database design, find and apply indices that make your queries execute faster), or then increase the timeout you allow the query to run before a timeout is thrown.

Those are your two options - take your pick.

UPDATE: a little googling reveals:

Dim cmd
Set cmd = Server.CreateObject("ADODB.Command")
cmd.CommandTimeout = 120   ' number of seconds

Marc