end if next
把结尾的", " 从我们建立的字符串中去掉 vStr = left(vStr, len(vStr) - 2) & ")" nStr = left(nStr, len(nStr) - 2) & ") "
把SQL语句整合起来 buildSQLInsert = iStr & nStr & vStr end function
if trim(request("fName")&request("lname")&request("age")) <> "" then response.write( buildSQLInsert("") & "<BR<") response.write( buildSQLInsert("NUM_AGE") & "<BR>") response.write( buildSQLInsert("lname,fname") & "<BR>") response.write( buildSQLInsert("mycheckbox,fname") & =<"<BR<") else %>
<html> <body> <form name=f method=post action="列表4.asp"> Gimme your:<br> First Name: <input type=text name="fName"<<br> Last Name: <input type=text name="lName"<<br> Age: <input type=text name="num_age"<<br> <input type="checkbox" value="Y" name="MyCheckBox"<Do you want this checked?<br> <input type="submit" value="Submit"> </form> </body> </html>
<% end if %>
列表 D: buildSQLInsert函数的最终版。
<% function buildSQLInsert( targetTable, omitFields) iStr = "insert into " & targetTable & " " vStr = "values (" nStr = "(" 在表单集合中循环,并建立起SQL语句的组成部分 for each x in request.form fieldName = uCase(x) 判断字段是否被省略? if inStr(uCase(omitFields),x) = 0 then fieldData = replace(request.form(fieldName), _ "", "") 如果没有数据,就插入 NULL if trim(fieldData) = "" the上一页 [1] [2] [3] [4] [5] [6] 下一页
|