Executing an SQL Server stored procedure from events
Calling the procedure without parameters.
If stored procedure doesn't return the recordset:
DB_Exec("EXEC StoredProcNameHere")
If stored procedure returns the recordset:
DB_Query("EXEC StoredProcNameHere")
Passing one of the field values as a parameter:
sql = DB_PrepareSQL("EXEC StoredProcNameHere ':1'", values("FieldName"))
DB_Exec(sql)
Executing MySQL stored procedure from the event
Calling the procedure without parameters.
If stored procedure doesn't return the recordset:
DB_Exec("CALL StoredProcNameHere")
If stored procedure returns the recordset:
DB_Query("CALL StoredProcNameHere")
Passing one of the field values as a parameter:
sql = DB_PrepareSQL("CALL StoredProcNameHere ':1'", values("FieldName"))
DB_Exec(sql)
Executing ORACLE stored procedure from the event
Calling the procedure without parameters.
If stored procedure doesn't return the recordset:
DB_Exec("BEGIN STOREDPROCNAME(); END;")
If stored procedure returns the recordset:
DB_Query("BEGIN STOREDPROCNAME(); END;")
Passing one of the field values as a parameter:
sql = DB_PrepareSQL("BEGIN STOREDPROCNAME(':1'); END;", values("FieldName") )
DB_Query(sql)
Executing MS Access query from the event
Calling the query without parameters:
dim cmd, dbConn
Set cmd = Server.CreateObject ("ADODB.Command")
set dbConn = getDefaultConnection()
set cmd.ActiveConnection = dbConn.conn
cmd.CommandText = "MyQueryNameHere"
cmd.CommandType = 4 ' adCmdStoredProc
cmd.Execute
Passing one of the field values as a parameter:
dim cmd, dbConn
set cmd = Server.CreateObject ("ADODB.Command")
set dbConn = getDefaultConnection()
set cmd.ActiveConnection = dbConn.conn
cmd.CommandText = "MyQueryNameHere '" & values("FieldName") & "'"
cmd.CommandType = 4
cmd.Execute
See also:
•Connecting to Oracle database
•Connecting to MS Access database