The db2 tutorial is: submit SQL statement (to) 3 using a form. List D: the final version of the buildSQLInsert function.
<%
Function buildSQLInsert (targetTable, omitFields)
IStr = "insert into" & targetTable &""
VStr = "values ("
NStr = "("
Loop in the form set and create an SQL statement component
For each x in request. form
FieldName = uCase (x)
Is the field omitted?
If inStr (uCase (omitFields), x) = 0 then
FieldData = replace (request. form (fieldName ),_
"","")
If no data exists, NULL is inserted.
If trim (fieldData) = "" then
FieldData = "NULL"
VStr = vStr & fieldData &","
NStr = nStr & fieldName &","
Else
TypeDelimPos = inStr (fieldName ,"_")
If typeDelimPos = 0 then
Is a text field
Create a field name list
NStr = nStr & fieldName &","
VStr = vStr &
[1] [2] [3] [4] [5] Next page
The db2 tutorial is: submit SQL statement (to) 3 using a form. "" & FieldData &","
Else
The field is of another type.
FieldType = left (fieldName, typeDelimPos-1)
FieldName = mid (fieldName, typeDelimPos + 1)
Add field names to the name list
NStr = nStr & fieldName &","
Converts the field type to uppercase to ensure matching.
Select case uCase (fieldType)
Case "NUM"
VStr = vStr & fieldData &","
Process unspecified types by text type
Case else
VStr = vStr & "" & fieldData &","
End select
End if
&
Previous Page [1] [2] [3] [4] [5] Next page
The db2 tutorial is: submit SQL statement (to) 3 using a form. Nbsp; end if
End if
Next
Remove "," from the string we created
VStr = left (vStr, len (vStr)-2 )&")"
NStr = left (nStr, len (nStr)-2 )&")"
Integrate SQL statements
BuildSQLInsert = iStr & nStr & vStr
End function
If trim (request ("fName") & request ("lname") & request ("age") <> "then
Response. write (buildSQLInsert ("")&" Response. write (buildSQLInsert ("NUM_AGE ")&"
")
Response. write (buildSQLInsert ("lname, fname ")&"
")
Response. write (buildSQLInsert ("mycheckbox, fname ")&
= <" Else
%>
<%
End if
%>
List D: the final version of the buildSQLInsert function.
<%
Function buildSQLInsert (targetTable, omitFields)
IStr = "insert into" & targetTable &""
VStr = "values ("
NStr = "("
Loop in the form set and create an SQL statement component
For each x in request. form
FieldName = uCase (x)
Is the field omitted?
If inStr (uCase (omitFields), x) = 0 then
FieldData = replace (request. form (fieldName ),_
"","")
If no data exists, NULL is inserted.
If trim (fieldData) = "" then
FieldData = "NULL"
VStr = vStr & fieldData &","
Previous Page [1] [2] [3] [4] [5] Next page
The db2 tutorial is: submit SQL statement (to) 3 using a form. NStr = nStr & fieldName &","
Else
TypeDelimPos = inStr (fieldName ,"_")
If typeDelimPos = 0 then
Is a text field
Create a field name list
NStr = nStr & fieldName &","
VStr = vStr & "" & fieldData &","
Else
The field is of another type.
FieldType = left (fieldName, typeDelimPos-1)
FieldName = mid (fieldName, typeDelimPos + 1)
Add field names to the name list
NStr = nStr & fieldName &","
Converts the field type to uppercase to ensure matching.
Select case uCase (fieldType)
& N
Previous Page [1] [2] [3] [4] [5] Next page
The db2 tutorial is: submit SQL statement (to) 3 using a form. Bsp; case "NUM"
VStr = vStr & fieldData &","
Process unspecified types by text type
Case else
VStr = vStr & "" & fieldData &","
End select
End if
End if
End if
Next
Remove "," from the string we created
VStr = left (vStr, len (vStr)-2 )&")"
NStr = left (nStr, len (nStr)-2 )&")"
Integrate SQL statements
BuildSQLInsert = iStr & nStr & vStr
End function
If trim (request ("fName") & request ("lname") & request ("age") <> "then
Response. write (buildSQLInsert ("")&" Response. write (buildSQLInsert ("NUM_AGE ")&"
")
Response. write (buildSQLInsert ("lname, fname ")&"
")
Response. write (buildSQLInsert ("mycheckbox, fname ")&
= <" Else
%>
<%
End if
%>
Previous Page [1] [2] [3] [4] [5]