Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to set connection timeout

Posted on 2012-03-31
4
Medium Priority
?
2,855 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 2000 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 2000 total points
ID: 37790729
"Provider=Microsoft.ACE.OLEDB.12.0; DataSource:\\DatabaseWRK\DataFiles\Client.accdb;Connect Timeout=30;"
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

704 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