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

Execute Non Query Sql Cmd (Signature 2)

Executes a non-query SQL command (such as INSERT, UPDATE, DELETE) on the specified SqlConnection and optionally returns an error message.

This function ensures that the connection is open before executing the command. Unlike the overload that returns an Integer , this version returns a String for error reporting. It does not rethrow exceptions and does not log errors.

VB
    Public Function ExecuteNonQuerySqlCmd(MyConnection As SqlConnection, 
                                          SqlCmd As String, 
                                          ReturnErrorMessage As Boolean) As String

        Try
            If Not MyConnection.State = ConnectionState.Open Then MyConnection.Open()

            Dim MyCmd As New SqlCommand(SqlCmd, MyConnection)
            MyCmd.ExecuteNonQuery()
            Return String.Empty

        Catch ex As Exception
            Return ex.Message
        End Try

    End Function
Posted by ipercube


© 2026 Ipercube Design