SqlExec

Runs SQL Command that needs no return
This is primarily useful for CREATE, DROP, INSERT, UPDATE or DELETE sql statements
then returns 0 or 1
If ConnString is passed as null, it will assume that we already have db connection open.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function SqlExec(byVal stSQLCmd, byVal ConnString)
    ' Runs SQL Command that needs no return
    '        This is primarily useful for CREATE, DROP, INSERT, UPDATE or DELETE sql statements
    '    then returns 0 or 1
    Dim oConn
    Set oConn                = Server.CreateObject("ADODB.Connection")
    On Error Resume Next
    If ConnString > "" Then ' Blank if we are already connected
        oConn.Open ConnString
    End If
    If Err Then
        Rett                    = 0
    Else
        Rett                    = 1
        oConn.Execute stSQLCmd
        If Err Then Rett = 0
    End If
    If ConnString > "" Then ' If we open it, we close it
        oConn.Close
        Set oConn = Nothing
    End If
    On Error GoTo 0
    SqlExec                    = Rett
End Function

byVal stSQLCmd, byVal ConnString

Views 206

Downloads 83

CodeID
DB ID