文章詳情頁
用表單來提交sql(轉)3
瀏覽:16日期:2023-03-24 09:22:45
正在看的db2教程是:用表單來提交sql(轉)3。 列表 D: buildSQLInsert函數(shù)的最終版。
<%
function buildSQLInsert( targetTable, omitFields)
iStr = "insert into " & targetTable & " "
vStr = "values ("
nStr = "("
在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒有數(shù)據(jù),就插入 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 &
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
&
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函數(shù)的最終版。
<%
function buildSQLInsert( targetTable, omitFields)
iStr = "insert into " & targetTable & " "
vStr = "values ("
nStr = "("
在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒有數(shù)據(jù),就插入 NULL
if trim(fieldData) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
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
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 = "("
在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒有數(shù)據(jù),就插入 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 ifend 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函數(shù)的最終版。
<%
function buildSQLInsert( targetTable, omitFields)
iStr = "insert into " & targetTable & " "
vStr = "values ("
nStr = "("
在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒有數(shù)據(jù),就插入 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
相關文章:
1. Oracle 刪除大量表記錄操作分析總結2. MySQL字符串拼接與分組拼接字符串實例代碼3. 用SQL語句查找Access中某表是否存在的小技巧4. Centos7 下mysql重新啟動MariaDB篇5. Window7安裝MariaDB數(shù)據(jù)庫及系統(tǒng)初始化操作分析6. MySQL該如何判斷不為空詳析7. MySQL之常用的MySQL優(yōu)化工具解讀8. Access 執(zhí)行SQL的方法9. MariaDB數(shù)據(jù)庫的外鍵約束實例詳解10. SQL Server使用CROSS APPLY與OUTER APPLY實現(xiàn)連接查詢
排行榜
