用表单来提交sql(转)3
更新时间:2007年03月06日 00:00:00 作者:
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud)
(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun)
正在看的db2教程是:用表单来提交sql(转)3。 列表 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) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
nStr = nStr & fieldName & ", "
else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr & 正在看的db2教程是:用表单来提交sql(转)3。"" & fieldData & ", "
else
字段是其它类型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名称列表
nStr = nStr & fieldName & ", "
把字段类型变成大写以确保匹配
select case uCase(fieldType)
case "NUM"
vStr = vStr & fieldData & ", "
把不明类型按文本型处理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
&正在看的db2教程是:用表单来提交sql(转)3。nbsp; end if
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("") & "
response.write( buildSQLInsert("NUM_AGE") & "
")
response.write( buildSQLInsert("lname,fname") & "
")
response.write( buildSQLInsert("mycheckbox,fname") &
=<"
else
%>
<%
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) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
正在看的db2教程是:用表单来提交sql(转)3。 nStr = nStr & fieldName & ", "
else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr & "" & fieldData & ", "
else
字段是其它类型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名称列表
nStr = nStr & fieldName & ", "
把字段类型变成大写以确保匹配
select case uCase(fieldType)
&n正在看的db2教程是:用表单来提交sql(转)3。bsp; case "NUM"
vStr = vStr & fieldData & ", "
把不明类型按文本型处理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
end if
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("") & "
response.write( buildSQLInsert("NUM_AGE") & "
")
response.write( buildSQLInsert("lname,fname") & "
")
response.write( buildSQLInsert("mycheckbox,fname") &
=<"
else
%>
<%
end if
%>
<%
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) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
nStr = nStr & fieldName & ", "
else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr & 正在看的db2教程是:用表单来提交sql(转)3。"" & fieldData & ", "
else
字段是其它类型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名称列表
nStr = nStr & fieldName & ", "
把字段类型变成大写以确保匹配
select case uCase(fieldType)
case "NUM"
vStr = vStr & fieldData & ", "
把不明类型按文本型处理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
&正在看的db2教程是:用表单来提交sql(转)3。nbsp; end if
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("") & "
response.write( buildSQLInsert("NUM_AGE") & "
")
response.write( buildSQLInsert("lname,fname") & "
")
response.write( buildSQLInsert("mycheckbox,fname") &
=<"
else
%>
<%
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) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
正在看的db2教程是:用表单来提交sql(转)3。 nStr = nStr & fieldName & ", "
else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr & "" & fieldData & ", "
else
字段是其它类型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名称列表
nStr = nStr & fieldName & ", "
把字段类型变成大写以确保匹配
select case uCase(fieldType)
&n正在看的db2教程是:用表单来提交sql(转)3。bsp; case "NUM"
vStr = vStr & fieldData & ", "
把不明类型按文本型处理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
end if
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("") & "
response.write( buildSQLInsert("NUM_AGE") & "
")
response.write( buildSQLInsert("lname,fname") & "
")
response.write( buildSQLInsert("mycheckbox,fname") &
=<"
else
%>
<%
end if
%>
相关文章
DB2新手使用的一些小笔记:新建实例、数据库路径不存在、客户端连接 .
这次,我们的DB2是被部署在Windows上的。Windows下有一个所谓的图形界面的客户端。不过似乎不大好用,遇到了一些问题,我们来解决吧2013-11-11
最新评论