troubleshooting Question Connection Timeout

Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland asked on
Visual Basic.NET
6 Comments3 Solutions573 ViewsLast Modified:

How would I apply a connection Timeout of 30 seconds to the following code

    Public Function DoesSQLTableExist(ByVal tblName As String, ByVal cnnStr As String) As Boolean

            ' Open connection to the database
            Dim dbConn As New SqlConnection(cnnStr)


            Dim restrictions(3) As String
            restrictions(2) = tblName
            Dim dbTbl As DataTable = dbConn.GetSchema("Tables", restrictions)

            If dbTbl.Rows.Count = 0 Then
                'Table does not exist
                DoesSQLTableExist = False
                'Table exists
                DoesSQLTableExist = True
            End If


        Catch ex As Exception
            MsgBox(ex.Message & " hhr5")
        End Try
    End Function
Join our community to see this answer!
Unlock 3 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros