>

ODBCTimeout Property

Applies To

QueryDef Object.

Description

Sets or returns the number of seconds the Microsoft Jet database engine waits before a timeout error occurs when a query is run on an ODBC database.

Settings and Return Values

The setting or return value is an integer representing the number of seconds that the Jet database engine waits before a timeout error occurs. The data type is Integer.

Remarks

When you're using an ODBC database, such as SQL Server, delays can occur because of network traffic or heavy use of the ODBC server. Rather than waiting indefinitely, you can specify how long the Jet database engine waits before it produces an error.

The default timeout value is 60 seconds. When the ODBCTimeout property is set to -1, the default value is used. When the ODBCTimeout property is set to 0, no timeout occurs.

The QueryTimeout property setting for a Database object overrides the default setting.

Setting the ODBCTimeout property of a QueryDef object overrides the values specified by the QueryTimeout property setting of the Database object containing the QueryDef object, but only for that QueryDef object.

See Also

QueryTimeout Property.

Example

This example sets the ODBCTimeout property to 120 seconds and then creates a query and runs it on a database on an ODBC server.


Dim dbsNorthwind As Database
Dim qdfCustomers As QueryDef, rstCustomers As Recordset
Set dbsNorthwind =  DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb")
' Create query.
Set qdfCustomers = dbsNorthwind.CreateQueryDef("All Cust", _
"SELECT * FROM Customers;") qdfCustomers.Connect = "ODBC;DSN=Human Resources; SERVER=HRSRVR: " & _
"UID=Smith; PWD=Sesame" ' Log in to server and run query. qdfCustomers.ODBCTimeout = 120 Set rstCustomers = qdfCustomers.OpenRecordset()
Example (Microsoft Access)

The following example sets the ODBCTimeout property to 120 seconds, creates a query, and runs it on a database on an ODBC server.


Sub SetTimeout()
    Dim dbs As Database
    Dim qdfCustomers As QueryDef, rstCustomers As Recordset

    ' Return Database variable that points to current database.
    Set dbs = CurrentDb
    ' Create QueryDef.
    Set qdfCustomers = dbs.CreateQueryDef("All Cust", _
"SELECT * FROM Customers;") qdfCustomers.Connect = "ODBC;DSN=HumanResources;SERVER=HRSRVR: " & _
"UID=Smith; PWD=Sesame" ' Log in to server and run query. qdfCustomers.ODBCTimeout = 120 Set rstCustomers = qdfCustomers.OpenRecordset() End Sub