Submit sql3 using Forms

Source: Internet
Author: User

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]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.