每次在操作數據庫的時候最煩的就是根據表單提交的內容寫sql語句
程序代碼
<%
Function insertStr(objForm
dim tbField()
dim tbfieldVal()
i=
for each objItem in objForm
redim preserve tbField(i)
tbField(i)=objItem
redim preserve tbfieldVal(i)
numPos=instr(numStr
if numPos<>
tbfieldVal(i)=trim(objForm(objItem))
else
tbfieldVal(i)=
end if
i=i+
next
insertStr=
End Function
Function updateStr(objForm
dim setFieldVal()
dim whereStrArr()
i=
t=
for each objItem in objForm
wherePos=instr(whereField
if wherePos=
redim preserve setFieldVal(i)
numPos=instr(numStr
if numPos<>
setFieldVal(i)=objItem&
else
setFieldVal(i)=objItem&
end if
i=i+
else
redim preserve whereStrArr(t)
numPos
if numPos
whereStrArr(t)=objItem&
else
whereStrArr(t)=objItem&
end if
t=t+
end if
next
wherePos
if wherePos
whereStr=
else
whereStrArray=whereStrArr
whereStr=
end if
updateStr=
End Function
Function updateStr
dim setFieldVal()
i=
for each objItem in objForm
redim preserve setFieldVal(i)
numPos=instr(numStr
if numPos<>
setFieldVal(i)=objItem&
else
setFieldVal(i)=objItem&
end if
i=i+
next
updateStr
End Function
From:http://tw.wingwit.com/Article/program/net/201311/13880.html