Solved

VB.net SQL Timeout Expired

Posted on 2014-11-03
2
203 Views
Last Modified: 2014-11-03
Hi. I am getting the following error
"The timeout period expired prior to completion of the operation or the server is not responding"
when I run the following code on view or table that has three million records.
Is there any way to extend the time before this errors out?

                sSQL = "SELECT Count(*) As MyCount FROM (" & oSQL & ") As X"

                Dim cn As New SqlConnection(oConnectionString)
                Dim cmd As New SqlCommand(sSQL, cn)
                cn.Open()

                Count_Rows_of_Query = cmd.ExecuteScalar.ToString

                If cn.State <> ConnectionState.Closed Then
                    cn.Close()
                End If
0
Comment
Question by:murbro
2 Comments
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40419439
Add the ";Connection Timeout=60" to the oConnectionString where 60 is the number of seconds.
0
 

Author Closing Comment

by:murbro
ID: 40419466
Thanks very much Vitor
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now