Solved

How to set connection timeout

Posted on 2012-03-31
4
2,543 Views
Last Modified: 2012-03-31
I am using vb.net and access 2007 database.

I need to change the value of the connection timeout value.

On the msdn for the oledbconnection.ConnectionTimeout Property, but that is ReadOnly.

Can you please give me the code to change the default value of the connection timeout value.

Thanks in advance.
0
Comment
Question by:baabaa_nl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
OCDan earned 500 total points
ID: 37790662
The default value is 15seconds, if you can't connect to the DB in this time then you likely have other problems that you need to resolve.

However, you can change it here in your VB Code connection string:
Public Sub CreateOleDbConnection()
    Dim myConnString As String = _
       "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;Connect Timeout=30;"
    Dim myConnection As New OleDbConnection(myConnString)
    myConnection.Open()
End Sub
0
 

Author Comment

by:baabaa_nl
ID: 37790726
I use a database file on my connectin string.

Below is the kind of connectionstring I use:


Provider=Microsoft.ACE.OLEDB.12.0; DataSource:\\DatabaseWRK\DataFiles\Client.accdb

Could you please insert the above connectinString into the connectinSting that you commented above. Because I am new to the kind of connection string that you have given me.

Thanks in advance.
0
 
LVL 12

Expert Comment

by:Anuradha Goli
ID: 37790728
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout(v=vs.71).aspx


[Visual Basic]
Public Sub CreateSqlConnection()
    Dim myConnection As New SqlConnection()
    myConnection.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30"
    myConnection.Open()
End Sub 'CreateSqlConnection

[C#]
public void CreateSqlConnection()
 {
    SqlConnection myConnection = new SqlConnection();
    myConnection.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";
    myConnection.Open();
 }
0
 
LVL 9

Assisted Solution

by:OCDan
OCDan earned 500 total points
ID: 37790729
"Provider=Microsoft.ACE.OLEDB.12.0; DataSource:\\DatabaseWRK\DataFiles\Client.accdb;Connect Timeout=30;"
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question