数据库 
首页 > 数据库 > 浏览文章

用表单来提交sql(转)3

(编辑:jimmy 日期: 2024/9/21 浏览:3 次 )
正在看的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 &

[1] [2] [3] [4] [5] 下一页

正在看的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       
&

上一页  [1] [2] [3] [4] [5] 下一页

正在看的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 & ", "
        

上一页  [1] [2] [3] [4] [5] 下一页

正在看的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

上一页  [1] [2] [3] [4] [5] 下一页

正在看的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
  %>

上一页  [1] [2] [3] [4] [5] 

上一篇:DB2编程序小小技巧
下一篇:sql 实现将空白值替换为其他值
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap