国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

用表單來提交sql - 1

2019-11-18 22:17:29
字體:
來源:轉載
供稿:網(wǎng)友
<%
'從表單中提取值
fName = request.form("fName")
lName = request.form("lName")
age = request.form("age")

'建立SQL語句
iStr = "insert into uData (fName, lName, age) "
iStr = iStr & "values ("
iStr = iStr & "'" & fName & "', "
iStr = iStr & "'" & lName & "', "
iStr = iStr & age & ")"

if trim(fName <> "") then
         response.write( iStr & "<BR>")
else
%>

<html>
<body>
<form name=f method=post action="listing1.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="age"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

<%
end if
  %>


列表 B:使用 request.form 來輕松建立SQL字符串。

<%
iStr = "insert into uData "
vStr = "values ("
nStr = "("

' 在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
         ' 建立字段名列表
         nStr = nStr & x & ", "
         ' 建立字段值列表
         if uCase(x) = "AGE" then
                  vStr = vStr & request.form(x) & ", "
         else
                  vStr = vStr & "'" & request.form(x) & "', "
         end if       
next

' 把結尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "

' 把SQL語句組裝起來
iStr = iStr & nStr & vStr

if trim(request("fName")) >> "" then
         response.write( iStr & ">BR>")
else
%>

<html>
<body>
<form name=f method=post action="列表2.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="age"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

<%
end if
  %>




發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 连城县| 锡林浩特市| 奇台县| 托克托县| 大渡口区| 广河县| 宜黄县| 岫岩| 苏尼特右旗| 云霄县| 湖口县| 泸溪县| 财经| 大兴区| 蕲春县| 三原县| 集安市| 抚宁县| 铅山县| 玛沁县| 吉首市| 新乐市| 香河县| 洪泽县| 奉贤区| 南京市| 甘肃省| 铜川市| 栾城县| 舒兰市| 河东区| 大英县| 双桥区| 西安市| 红原县| 阳东县| 苏尼特左旗| 凤台县| 石门县| 象山县| 平湖市|