Execute An SQL Statement

Search

 by Remas Wojciechowski

This function executes an SQL Statement against a given connection and returns the resulting recordset. A closed recordset is returned for a non–row-returning SQL statement.

Parameters

strConnectionString
The connection string to the database
strSQL
The SQL statement

Source Code

' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
' Function: db_Execute
'
'
Function db_Execute(ByVal strConnectionString, ByVal strSQL)
  Dim objConn
  Set objConn = Server.CreateObject("ADODB.Connection")
  objConn.Open strConnectionString
  Set db_Execute = objConn.Execute(strSQL)
  objConn.Close
  Set objConn = Nothing
End Function