Skip to sidebar Skip to content
Ipercube Technical
Jack of all trades, master of none
Date: Time: - Stardate:
Welcome, Log in by clicking  Here!
SS64
MDN
Stack
Code
GitHub
Wiki
Convert
V Studio
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions
Ipercube Technical
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions

Check Sql Connection

Checks whether a given SqlConnection can be successfully opened.

If the connection is already open, it is closed immediately after the check. If an exception occurs during the attempt to open the connection, the function returns False .

VB
    Public Function CheckSqlConnection(MyConnection As SqlConnection) As Boolean
    
        Try
            If Not MyConnection.State = ConnectionState.Open Then MyConnection.Open()
        Catch ex As Exception
            Return False
        End Try

        If MyConnection.State = ConnectionState.Open Then MyConnection.Close()
        Return True
    End Function
Posted by ipercube


© 2026 Ipercube Design