文章詳情頁(yè)
用表單來(lái)提交sql(轉(zhuǎn))3
瀏覽:72日期:2023-03-24 09:22:45
正在看的db2教程是:用表單來(lái)提交sql(轉(zhuǎn))3。 列表 D: buildSQLInsert函數(shù)的最終版。
<%
function buildSQLInsert( targetTable, omitFields)
iStr = "insert into " & targetTable & " "
vStr = "values ("
nStr = "("
在表單集合中循環(huán),并建立起SQL語(yǔ)句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒(méi)有數(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
字段是其它類(lèi)型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名稱(chēng)列表
nStr = nStr & fieldName & ", "
把字段類(lèi)型變成大寫(xiě)以確保匹配
select case uCase(fieldType)
case "NUM"
vStr = vStr & fieldData & ", "
把不明類(lèi)型按文本型處理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
&
end if
next
把結(jié)尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "
把SQL語(yǔ)句整合起來(lái)
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語(yǔ)句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒(méi)有數(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
字段是其它類(lèi)型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名稱(chēng)列表
nStr = nStr & fieldName & ", "
把字段類(lèi)型變成大寫(xiě)以確保匹配
select case uCase(fieldType)
&n
vStr = vStr & fieldData & ", "
把不明類(lèi)型按文本型處理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
end if
end if
next
把結(jié)尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "
把SQL語(yǔ)句整合起來(lái)
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語(yǔ)句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒(méi)有數(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] 下一頁(yè)
正在看的db2教程是:用表單來(lái)提交sql(轉(zhuǎn))3。"" & fieldData & ", "else
字段是其它類(lèi)型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名稱(chēng)列表
nStr = nStr & fieldName & ", "
把字段類(lèi)型變成大寫(xiě)以確保匹配
select case uCase(fieldType)
case "NUM"
vStr = vStr & fieldData & ", "
把不明類(lèi)型按文本型處理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
&
上一頁(yè) [1] [2] [3] [4] [5] 下一頁(yè)
正在看的db2教程是:用表單來(lái)提交sql(轉(zhuǎn))3。nbsp; end ifend if
next
把結(jié)尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "
把SQL語(yǔ)句整合起來(lái)
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語(yǔ)句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒(méi)有數(shù)據(jù),就插入 NULL
if trim(fieldData) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
上一頁(yè) [1] [2] [3] [4] [5] 下一頁(yè)
正在看的db2教程是:用表單來(lái)提交sql(轉(zhuǎn))3。 nStr = nStr & fieldName & ", "else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr & "" & fieldData & ", "
else
字段是其它類(lèi)型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名稱(chēng)列表
nStr = nStr & fieldName & ", "
把字段類(lèi)型變成大寫(xiě)以確保匹配
select case uCase(fieldType)
&n
上一頁(yè) [1] [2] [3] [4] [5] 下一頁(yè)
正在看的db2教程是:用表單來(lái)提交sql(轉(zhuǎn))3。bsp; case "NUM"vStr = vStr & fieldData & ", "
把不明類(lèi)型按文本型處理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
end if
end if
next
把結(jié)尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "
把SQL語(yǔ)句整合起來(lái)
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
%>
上一頁(yè) [1] [2] [3] [4] [5]
標(biāo)簽:
DB2
相關(guān)文章:
1. SQLite3數(shù)據(jù)庫(kù)的介紹和使用教程(面向業(yè)務(wù)編程-數(shù)據(jù)庫(kù))2. mysql獲取當(dāng)前日期年月的兩種實(shí)現(xiàn)方式3. 為SQLite3提供一個(gè)ANSI到UTF8的互轉(zhuǎn)函數(shù)4. Mysql/MariaDB啟動(dòng)時(shí)處于進(jìn)度條狀態(tài)導(dǎo)致啟動(dòng)失敗的原因及解決辦法5. SQLite 性能優(yōu)化實(shí)例分享6. ubuntu下使用SQLite3的基本命令7. Microsoft Office Access添加字段的方法8. Microsoft Office Access取消主鍵的方法9. sql server 2005 批量導(dǎo)入導(dǎo)出10. MariaDB性能調(diào)優(yōu)工具mytop的使用詳解
排行榜
