%@LANGUAGE="VBSCRIPT"%>
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) <> "") Then
MM_editConnection = MM_aCon_STRING
MM_editTable = "athleticsT"
MM_editRedirectUrl = "thankyou.asp"
MM_fieldsStr = "Element|value|a|value|b|value|Element2|value|Element3|value|Element4|value|Element5|value|a2|value|b2|value|Element6|value|Element7|value|0a|value|0b|value|a3|value|b3|value|c|value|d|value|e|value|f|value|g|value|a4|value|b4|value|c2|value|d2|value|e2|value|f2|value|a5|value|b5|value|c3|value|d3|value|e3|value|a6|value|Element8|value|ma|value|mb|value|mc|value|md|value|me|value|la|value|lb|value|lc|value|ld|value|a7|value|b6|value|c4|value|d4|value|e4|value|f3|value|g2|value|h|value|i|value|j|value|k|value|l|value|m|value|n|value|a8|value|b7|value|bb|value|c5|value|d5|value|e5|value|f4|value|g3|value|h2|value|i2|value|j2|value"
MM_columnsStr = "1|',none,''|2a|',none,''|2b|',none,''|3|',none,''|4|',none,''|5|',none,''|6|',none,''|7a|',none,''|7b|',none,''|8|',none,''|9|',none,''|10a|none,1,0|10b|none,1,0|11a|none,1,0|11b|none,1,0|11c|none,1,0|11d|none,1,0|11e|none,1,0|11f|',none,''|11g|',none,''|12a|none,1,0|12b|none,1,0|12c|none,1,0|12d|none,1,0|12e|none,1,0|12f|none,1,0|13a|none,1,0|13b|none,1,0|13c|none,1,0|13d|none,1,0|13e|none,1,0|14a|none,1,0|15|none,1,0|15ma|none,1,0|15mb|none,1,0|15mc|none,1,0|15md|none,1,0|15me|none,1,0|15la|none,1,0|15lb|none,1,0|15lc|none,1,0|15ld|none,1,0|16a|none,1,0|16b|none,1,0|16c|none,1,0|16d|none,1,0|16e|none,1,0|16f|none,1,0|16g|none,1,0|16h|none,1,0|16i|none,1,0|16j|none,1,0|16k|none,1,0|16l|none,1,0|16m|none,1,0|16n|none,1,0|17a|none,1,0|17b|none,1,0|17bb|',none,''|17c|none,1,0|17d|none,1,0|17e|none,1,0|17f|none,1,0|17g|',none,''|17h|',none,''|17i|',none,''|17j|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),",")
Delim = MM_typeArray(0)
If (Delim = "none") Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>