判断用户的选择问题?????

coffeegirl 2002-07-23 06:32:18
strSql="INSERT INTO fktable(ifopition,productsort,othersort,fkcontent,authorname,email,tel,fax)" _
& " VALUES(" & ifopition & ",'" & productsort & "','" & othersort & "','" & fkcontent & "','" & authorname & "','" & email & "','" & tel & "','" & fax & "')"

值是从表单中取得的,其中有几个值是可以为空的,用户可以填也可以不填,
现在问题是:
怎样判断用户有没有填这个值,填了的值就增添到数据库的相关字段中,没有填的值数据库的相关字段就为空值,用什么方法实现????
怎样改写这个sql语句?????
...全文
87 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
eldertiger 2002-07-23
  • 打赏
  • 举报
回复
我喜欢这样做,虽然可能比较土:
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&")"
meizz 2002-07-23
  • 打赏
  • 举报
回复
唉,这样更精简些:
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"))&"')"
meizz 2002-07-23
  • 打赏
  • 举报
回复
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&"')"

这样每个值都有一个空的初始值了。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧