David's ASP Database Machine - 2

<% strAction= Request.form("Action") strTable= Request.form("Table") intCounter= 1 DO UNTIL intCounter > 20 FieldD= "D"& intCounter FieldName= "T"& intCounter DataType= "DT"& intcounter BoxType= "FT"& intCounter ' Response.write FieldName &"
" FieldD= Request.form(FieldD) FieldName= Request.form(FieldName) DataType= Request.form(DataType) BoxType= Request.form(BoxType) ' Response.write "Field: "& FieldName &"
" ' Exit loop if no data in Field Name field If FieldName= "" then Exit Do End If ' FIELD NAMES and VALUES list for SQL INSERT + Request.Form code ' First Field If intCounter= 1 then strFieldNames= FieldName If DataType= "str" then strValues= """ _
&""'""& " & DataType & FieldName &" & ""'" strRequestLine= "str"& FieldName &"= Request.form("""& FieldName &""")" strUpdate= FieldName &"= '""& str"& FieldName &" &""'" ElseIf DataType= "int" then strValues= """ _
&""'& " & DataType & FieldName &" &' "'" strRequestLine= "int"& FieldName &"= Request.form("""& FieldName &""")" strUpdate= FieldName &"= '& str"& FieldName &" &'" ElseIf DataType= "bln" then strValues= """ _
&""'""& " & DataType & FieldName &" & """'" strRequestLine= "bln"& FieldName &"= Request.form("""& FieldName &""")" strUpdate= FieldName &"= '""& bln"& FieldName &" &""'" ElseIf DataType= "dat" then strValues= """ _
&""'""& " & DataType & FieldName &" & """'" strRequestLine= "dat"& FieldName &"= Request.form("""& FieldName &""")" strUpdate= FieldName &"= '""& dat"& FieldName &" &""'" End If ' Response.write "RequestLine: "& strRequestLine &"
" strRequestForm= strRequestLine &"
" ' Response.write "RequestForm: "& strRequestForm &"
" Else ' Subsequent Fields strFieldNames= strFieldNames &", "& FieldName If DataType= "str" then strValues= strValues &", "" _
&""'""& " & DataType & FieldName &" & ""'" strRequestLine= "str"& FieldName &"= Request.form("""& FieldName &""")" strUpdate= strUpdate &", "& FieldName &"= '""& str"& FieldName &" &""'" ElseIf DataType= "int" then strValues= strValues &", "" _
&""'& " & DataType & FieldName &" &' "'" strRequestLine= "int"& FieldName &"= Request.form("""& FieldName &""")" strUpdate= strUpdate &", "& FieldName &"= '& int"& FieldName &" &'" ElseIf DataType= "bln" then strValues= strValues &", "" _
&""'""& " & DataType & FieldName &" & ""'" strRequestLine= "str"& FieldName &"= Request.form("""& FieldName &""")" strUpdate= strUpdate &", "& FieldName &"= '""& bln"& FieldName &" &""'" ElseIf DataType= "dat" then strValues= strValues &", "" _
&""'""& " & DataType & FieldName &" & ""'" strRequestLine= "str"& FieldName &"= Request.form("""& FieldName &""")" strUpdate= strUpdate &", "& FieldName &"= '""& dat"& FieldName &" &""'" End If ' Response.write "RequestLine: "& strRequestLine &"
" strRequestForm= strRequestForm & strRequestLine &"
" End If %> <% intCounter= intCounter+1 Loop %>

Code to fetch data from form.....

<% Response.write strRequestForm %>

SQL INSERT statement.....

<% Response.write "SQL1= "" " Response.write "INSERT into "& strTable &" ("& strFieldNames &") "" _
&"" VALUES ("& strValues &")" Response.write " "" " %>

SQL UPDATE statement.....

<% Response.write "SQL2= "" " Response.write "Update "& strTable &" SET "& strUpdate Response.write " "" " %>

Input Form...
--- Start form ---

<% intCounter= 1 DO UNTIL intCounter > 20 FieldD= "D"& intCounter FieldName= "T"& intCounter DataType= "DT"& intcounter BoxType= "FT"& intCounter ' Response.write FieldName &"
" FieldD= Request.form(FieldD) FieldName= Request.form(FieldName) DataType= Request.form(DataType) BoxType= Request.form(BoxType) ' Response.write "Field: "& FieldName &"
" ' Exit loop if no data in Field Name field If FieldName= "" then Exit Do End If %> <% If BoxType= "TextBox" then %> <%ElseIf BoxType= "DropDown" then %> <%ElseIf BoxType= "Checkbox" then %> <%ElseIf BoxType= "RadioButton" then %> <% Else %> <% End If %> <% intCounter= intCounter+1 Loop %>

Database

Insert New Record - 1

<%= intCounter %> <%= FieldD %>Unknown form field type!
 

Check your entry for errors, then click "Submit" button.

--- End form ---

SQL SELECT for Update form

SQL3= "Select * from Table/Query"

Update Form...
--- Start form ---

<% intCounter= 1 DO UNTIL intCounter > 20 FieldD= "D"& intCounter FieldName= "T"& intCounter DataType= "DT"& intcounter BoxType= "FT"& intCounter ' Response.write FieldName &"
" FieldD= Request.form(FieldD) FieldName= Request.form(FieldName) DataType= Request.form(DataType) BoxType= Request.form(BoxType) ' Response.write "Field: "& FieldName &"
" ' Exit loop if no data in Field Name field If FieldName= "" then Exit Do End If %>
<% If BoxType= "TextBox" then %> <%ElseIf BoxType= "DropDown" then %> <%ElseIf BoxType= "Checkbox" then %> <%ElseIf BoxType= "RadioButton" then %> <% Else %> <% End If %> <% intCounter= intCounter+1 Loop %>

Database

Update Record - 1

<%= intCounter %> <%= FieldD %> Unknown form field type!
 

Check your entry for errors, then click "Submit" button.

--- End form ---

Home | Back
David's home page