PostIt.asp passes three parameters to the PostActions method: oRequest (a Request object), oResponse (a Response object), and optionally ConnectionString (a string). PostActions creates an instance of the ADODB Command object and loops through the hidden procname input fields on the form. The following code fragment illustrates this process. All forms, with the exception of PersonGroup.htm, have one procname field. The update function in the PersonGroup.js file shows how multiple hidden fields are created on the fly to store the names of stored procedures.
For Each nameSProc In oRequest.Form("procName")
.CommandText = nameSProc
Select Case UCase(oRequest.Form("actionBtn"))
…
Next
Inside the loop, code identifies the table action, which is stored in a hidden field named actionbtn. The ADD action, which the following code fragment illustrates, calls the methods execForm, reportErrors, and updateView. The ADD action also captures the unique identifier of the new record in a variable, which is passed to the updateView method. The "@" prefix indicates that this variable is an output parameter from a stored procedure.
Case "ADD"
Call execForm(oCommand, oRequest, oResponse)
Call reportErrors(oCommand, oResponse)
returnId = oCommand.Parameters("@" & oRequest.Form("tableName") & "Id")
Call updateView("ADD", returnId, oResponse)
The CHANGE action, which the the following code fragment illustrates, calls execForm, reportErrors, and updateView. It captures the ID of the current record and passes it to the updateView method.
Case "CHANGE"
returnId = oRequest.Form("Id")
Call execForm(oCommand, oRequest, oResponse)
Call reportErrors(oCommand, oResponse)
Call updateView("CHANGE", returnId, oResponse)
The DELETE action, which the following code fragment illustrates, creates a parameter. This parameter is the concatenation of "@", the name of a table, and the value of "Id". The stored procedure runs and PostActions calls execForm, reportErrors, and updateView.
Case "DELETE"
returnId = oRequest.Form("Id")
.Parameters.Append .CreateParameter("@" & oRequest.Form("tableName") & "Id", adInteger, adParamInput, 4, returnId)
Execute
Call reportErrors(oCommand, oResponse)
Call updateView("DELETE", returnId, oResponse)