Avatar of Murray Brown
Murray Brown
Flag for United Kingdom of Great Britain and Northern Ireland asked on

VB.net Connection Timeout

Hi

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
        Try

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

            dbConn.Open()

            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
            Else
                'Table exists
                DoesSQLTableExist = True
            End If

            dbTbl.Dispose()
            dbConn.Close()
            dbConn.Dispose()

        Catch ex As Exception
            MsgBox(ex.Message & " hhr5")
        End Try
    End Function

Open in new window

Visual Basic.NET

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon
SOLUTION
Pawan Kumar

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Murray Brown

ASKER
Hi. Thanks. How would I change my code to do that?
SOLUTION
Pallavi Godse

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Murray Brown

ASKER
Hi. I am still not sure how to alter my actual code
ASKER CERTIFIED SOLUTION
Scott McDaniel (EE MVE )

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Murray Brown

ASKER
Thanks very much
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck