Solved

How to set connection timeout

Posted on 2012-03-31
4
2,469 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

679 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