判断用户的选择问题?????
strSql="INSERT INTO fktable(ifopition,productsort,othersort,fkcontent,authorname,email,tel,fax)" _
& " VALUES(" & ifopition & ",'" & productsort & "','" & othersort & "','" & fkcontent & "','" & authorname & "','" & email & "','" & tel & "','" & fax & "')"
值是从表单中取得的,其中有几个值是可以为空的,用户可以填也可以不填,
现在问题是:
怎样判断用户有没有填这个值,填了的值就增添到数据库的相关字段中,没有填的值数据库的相关字段就为空值,用什么方法实现????
怎样改写这个sql语句?????
问题点数:100、回复次数:3Top
1 楼meizz(梅花雪)回复于 2002-07-23 18:41:20 得分 85
dim ifopition,productsort,othersort,fkcontent,authorname,email,tel,fax
ifopition = ""
productsort = ""
othersort = ""
fkcontent = ""
authorname = ""
email = ""
tel = ""
fax = ""
ifopition = Trim(Request.Form("ifopition"))
productsort = Trim(Request.Form("productsort"))
othersort = Trim(Request.Form("othersort"))
fkcontent = Trim(Request.Form("fkcontent"))
authorname = Trim(Request.Form("authorname"))
email = Trim(Request.Form("email"))
tel = Trim(Request.Form("tel"))
fax = Trim(Request.Form("fax"))
strSql="INSERT INTO fktable(ifopition,productsort,othersort,fkcontent,authorname,email,tel,fax)VALUES("&ifopition&",'"&productsort&"','"&othersort&"','"&fkcontent&"','"&authorname&"','"&email&"','"&tel&"','"&fax&"')"
这样每个值都有一个空的初始值了。Top
2 楼meizz(梅花雪)回复于 2002-07-23 18:56:02 得分 0
唉,这样更精简些:
strSql="INSERT INTO fktable"& _
"(ifopition,productsort,othersort,fkcontent,authorname,email,tel,fax)VALUES("& _
Trim(Request.Form("ifopition"))&",'"& _
Trim(Request.Form("productsort"))&"','"& _
Trim(Request.Form("othersort"))&"','"& _
Trim(Request.Form("fkcontent"))&"','"& _
Trim(Request.Form("authorname"))&"','"& _
Trim(Request.Form("email"))&"','"& _
Trim(Request.Form("tel"))&"','"& _
Trim(Request.Form("fax"))&"')"Top
3 楼eldertiger(现在是菜鸟)回复于 2002-07-23 21:10:08 得分 15
我喜欢这样做,虽然可能比较土:
user_email=request("user_email")
user_pwd=makepassword
str1="user_name,user_pwd,user_email"
str2="'"&user_name&"','"&user_pwd&"','"&user_email&"'"
user_true_name=request("user_true_name")
if user_true_name<>"" then
str1=str1&",user_true_name"
str2=str2&",'"&user_true_name&"'"
end if
user_code=request("user_code")
if user_code<>"" then
str1=str1&",user_code"
str2=str2&","&user_code
end if
sql="insert into table_name ("&str1&") values ("&str2&")"
Top
相关问题
- 请问如何判断用户在printerSetup中选择了“取消”?
- 在javascript中我想判断用户选择了哪个radio应该怎么写?
- 问如何判断用户在TQuickRep的printerSetup()中选择了“取消”?
- 如何判断用户选择的是TreeView的第几级节点
- VBA中如何判断用户在Excel的表中选择了一整行?
- 如果用户一个都没选,我怎么用javascript判断呢?让用户选择。
- 用户名判断问题
- 我想用一个vbscript语句对话框来判断用户的选择,但无法完成!!!!
- 有七八组单选框,怎么判断用户至少选择了两组单选框??????
- 如何可以显示一个用户选择判断对话框?选择“确定”继续,选择“取消”取消后续操作。




