Runtime error 3709: The Connection Cannot be Used [Fix]

Check the SQL query if you encounter this error

Reading time icon 4 min. read


Readers help support Windows Report. When you make a purchase using links on our site, we may earn an affiliate commission. Tooltip Icon

Read the affiliate disclosure page to find out how can you help Windows Report effortlessly and without spending any money. Read more

Key notes

  • Runtime error 3709 occurs when you have an error in your VBS code.
  • Issues like SQL query problems, connection timeouts, and insufficient permissions can cause the error.
runtime error 3709

Users can run into Runtime error 3709 when setting a company as default in Microsoft FRx. It comes with an error message the connection cannot be used to perform this operation. It is either closed or invalid in this context. However, this article will take you through how to fix the error.

Likewise, you may be interested in our guide about resolving the Runtime error: could not call proc on Windows PCs.

What causes runtime error 3709?

Runtime error 3709 typically occurs in the context of database applications when using ActiveX Data Objects (ADO) to interact with a database. Here are some common causes of this error:

  • Connection issues – This can include an incorrect or improperly formatted connection string, an invalid server address, or an inaccessible or offline database. It could also occur if there is a problem with the network connection.
  • SQL query problems – If the SQL query is invalid or contains errors, it can result in runtime error 3709. This may include syntax errors, misspelled table or column names, missing or incorrect parameters, or issues with the query logic.
  • Insufficient permissions – The error can occur if the user account or credentials connecting to the database do not have the necessary permissions to perform the requested operation.
  • Data provider issues – The data provider being used to connect to the database, such as the Microsoft OLE DB Provider for SQL Server, may have compatibility issues or be incorrectly installed.
  • Connection timeouts – If the connection to the database times out due to inactivity or if the connection timeout value is set too low, it can result in runtime error 3709. Adjusting the connection timeout value to a higher duration can help mitigate this issue.

The specific cause of runtime error 3709 can vary depending on the application, database, and programming language used. Nonetheless, we’ll discuss some basic steps to resolve the error.

How can I fix the runtime error 3709?

Before proceeding with any advanced steps, proceed with the following preliminary checks:

  • Check the connection string – Verify that the connection string used to connect to the database is correct. It should include the server address, database name, and authentication details.
  • Verify database connectivity – Ensure the database server is running and accessible from the machine where the code runs. Check the network connectivity and permissions to ensure the code can connect to the database.
  • Validate the SQL query – If an error occurs while executing an SQL query, review the query for any errors. Check for correct table and column names, proper syntax, and parameter usage.
  • Verify user permissions – Confirm that the user account or credentials you use to connect to the database have sufficient permissions to perform the required operations.
  • Update data provider or database driver – If you use a specific data provider or database driver, ensure you install it correctly. Consider updating or reinstalling the provider or driver to eliminate compatibility issues.

If the error persists after trying the above steps, go ahead with the fixes below:

1. Declare the reference properly

  1. Open your code in the code editor.
  2. Make sure that references are declared properly, like this, and save changes:Dim cn As ADODB.Connection Set cn = New ADODB.Connection
  3. Save changes.

Also, you need to use the Recordset properly. To do this, follow the same steps as above and input your code as such:

Dim strSQL As New ADODB.Command
strSQL.ActiveConnection = cn
strSQL.CommandText = "SELECT * FROM Table1"
strSQL.CommandType = adCmdText

2. Check the SQL query

  1. Open code in your editor.
  2. Locate the SQL query.
  3. Change the code from this input: strSQL = "SELECT * FROM [" & Worksheet & "$] Where Exhibitor = '" & strEntry & "'," & rsCon to strSQL = "SELECT * FROM [" & Worksheet & "$] Where Exhibitor = '" & strEntry & "'"
  4. Then save the changes.

Conclusively, you can check our article about runtime error 53 and ways to fix it. Also, we have a comprehensive review of the best runtime error repair tools for Windows.

If you have further questions or suggestions regarding this guide, kindly drop them in the comments section.

More about the topics: Runtime Errors