The DB2 tutorial you are looking at is: Submit SQL (EXT) 3 with a table forms. List D:buildsqlinsert The final version of the function.
<%
function Buildsqlinsert (targettable, Omitfields)
ISTR = "INSERT INTO" & Targettable & ""
Vstr = "VALUES ("
Nstr = "("
Looping through a collection of forms and building up parts of SQL statements
For each x in Request.Form
FieldName = uCase (x)
Determine if the field is omitted?
If InStr (UCase (Omitfields), x) = 0 Then
Fielddata = replace (Request.Form (fieldName), _
"", "")
If there is no data, insert NULL
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 list of field names
Nstr = nstr & FieldName & ","
Vstr = Vstr &
[1] [2] [3] [4] [5] Next page
The DB2 tutorial you are looking at is: Submit SQL (EXT) 3 with a table forms. "" & Fielddata & ","
Else
fields are other types
FieldType = Left (FieldName, typeDelimPos-1)
FieldName = Mid (FieldName, Typedelimpos + 1)
Add field name to Name list
Nstr = nstr & FieldName & ","
Capitalize field type to ensure match
Select Case UCase (FieldType)
Case "NUM"
Vstr = vstr & Fielddata & ","
To treat unknown types as text
Case Else
Vstr = Vstr & "" & Fielddata & ","
End Select
End If
&
prev [1] [2] [3] [4] [5] Next page
The DB2 tutorial you are looking at is: Submit SQL (EXT) 3 with a table forms. nbsp End If
End If
Next
Remove the end of the "," from the string we established
Vstr = Left (Vstr, Len (VSTR)-2) & ")"
Nstr = Left (Nstr, Len (NSTR)-2) & ")"
Integrate the 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
%>
Gimme your:
The Name:
Last Name:
Age:
<%
End If
%>
List D:buildsqlinsert The final version of the function.
<%
function Buildsqlinsert (targettable, Omitfields)
ISTR = "INSERT INTO" & Targettable & ""
Vstr = "VALUES ("
Nstr = "("
Looping through a collection of forms and building up parts of SQL statements
For each x in Request.Form
FieldName = uCase (x)
Determine if the field is omitted?
If InStr (UCase (Omitfields), x) = 0 Then
Fielddata = replace (Request.Form (fieldName), _
"", "")
If there is no data, insert NULL
If trim (fielddata) = "" Then
Fielddata = "NULL"
Vstr = vstr & Fielddata & ","
prev [1] [2] [3] [4] [5] Next page
The DB2 tutorial you are looking at is: Submit SQL (EXT) 3 with a table forms. Nstr = nstr & FieldName & ","
Else
Typedelimpos = InStr (FieldName, "_")
If Typedelimpos = 0 Then
is a text field
Create a list of field names
Nstr = nstr & FieldName & ","
Vstr = Vstr & "" & Fielddata & ","
Else
fields are other types
FieldType = Left (FieldName, typeDelimPos-1)
FieldName = Mid (FieldName, Typedelimpos + 1)
Add field name to Name list
Nstr = nstr & FieldName & ","
Capitalize field type to ensure match
Select Case UCase (FieldType)
&n
prev [1] [2] [3] [4] [5] Next page
The DB2 tutorial you are looking at is: Submit SQL (EXT) 3 with a table forms. Bsp Case "NUM"
Vstr = vstr & Fielddata & ","
To treat unknown types as text
Case Else
Vstr = Vstr & "" & Fielddata & ","
End Select
End If
End If
End If
Next
Remove the end of the "," from the string we established
Vstr = Left (Vstr, Len (VSTR)-2) & ")"
Nstr = Left (Nstr, Len (NSTR)-2) & ")"
Integrate the 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
%>
Gimme your:
The Name:
Last Name:
Age:
<%
End If
%>
prev [1] [2] [3] [4] [5]
<>