Solved

VB.net SQL Timeout Expired

Posted on 2014-11-03
2
206 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 46

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.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Viewers will learn how the fundamental information of how to create a table.

932 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

11 Experts available now in Live!

Get 1:1 Help Now