关于asp代码 向另外一个表中写入数据的问题
有这样一段代码是用户提交注册信息以后,向"user"表中写入信息的.username=htmlEncode2(request.form("username"))passw...
有这样一段代码是用户提交注册信息以后,向"user"表中写入信息的.
username=htmlEncode2(request.form("username"))
password=htmlEncode2(request.form("password"))
email=htmlEncode2(request.form("email"))
Tel=htmlEncode2(request.form("Tel"))
AccountPlace=htmlEncode2(request.form("AccountPlace"))
Usertype=htmlEncode2(request.form("Usertype"))
Set fso = Server.CreateObject("Scripting.FileSystemObject")
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
我现在又在注册页面增加了几个选项:time,profession,income,
怎么把这几个信息写入另外一个表"choice"中去呢?
一楼说的试了好象还是不行,choice表里面还是空的. 展开
username=htmlEncode2(request.form("username"))
password=htmlEncode2(request.form("password"))
email=htmlEncode2(request.form("email"))
Tel=htmlEncode2(request.form("Tel"))
AccountPlace=htmlEncode2(request.form("AccountPlace"))
Usertype=htmlEncode2(request.form("Usertype"))
Set fso = Server.CreateObject("Scripting.FileSystemObject")
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
我现在又在注册页面增加了几个选项:time,profession,income,
怎么把这几个信息写入另外一个表"choice"中去呢?
一楼说的试了好象还是不行,choice表里面还是空的. 展开
5个回答
展开全部
<%
username=htmlEncode2(request.form("username"))
password=htmlEncode2(request.form("password"))
email=htmlEncode2(request.form("email"))
Tel=htmlEncode2(request.form("Tel"))
AccountPlace=htmlEncode2(request.form("AccountPlace"))
Usertype=htmlEncode2(request.form("Usertype"))
''---------------------
''要改下名字.不能用time
''添加了的times,profession,income
times=htmlEncode2(request.form("对应前一表单元素的名字"))
profession=htmlEncode2(request.form("对应前一表单元素的名字"))
income=htmlEncode2(request.form("对应前一表单元素的名字"))
''------------------------
'''----------?????????????????
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'''不是说要写入数据库吗?怎么搞到文本文件里去了.
''-------------?????????????????
''-----写入数据库
set rs=server.CreateObject ("adodb.recordset")
''------------
'''以下是你原来的
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
''''----加这句
set rs=nothing
'''写入另一个表.
set rs2=server.CreateObject ("adodb.recordset")
userpath=fullpath&username
sql="select * from [choice]"
rs2.open sql,conn,1,3
rs2.addnew
'''------------------------------------
''以下的是你原来的,你要不要.不要就删除了.
rs2("username")=username
rs2("password")=password
rs2("email")=email
rs2("Tel")=Tel
rs2("sitetype")=sitetype
rs2("AccountPlace")=AccountPlace
rs2("Usertype")=Usertype
''''--------------------------------------
''-----------------------------
''''以下的是你加上的.
''''首先你的这个表要有字段times,profession,income,才可以写入啊.
rs("times")=times
rs2("profession")=profession
rs2("income")=income
rs2.update
''---打完收工.如果你还要操作,也可先不收工.
set rs2=nothing
%>
username=htmlEncode2(request.form("username"))
password=htmlEncode2(request.form("password"))
email=htmlEncode2(request.form("email"))
Tel=htmlEncode2(request.form("Tel"))
AccountPlace=htmlEncode2(request.form("AccountPlace"))
Usertype=htmlEncode2(request.form("Usertype"))
''---------------------
''要改下名字.不能用time
''添加了的times,profession,income
times=htmlEncode2(request.form("对应前一表单元素的名字"))
profession=htmlEncode2(request.form("对应前一表单元素的名字"))
income=htmlEncode2(request.form("对应前一表单元素的名字"))
''------------------------
'''----------?????????????????
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'''不是说要写入数据库吗?怎么搞到文本文件里去了.
''-------------?????????????????
''-----写入数据库
set rs=server.CreateObject ("adodb.recordset")
''------------
'''以下是你原来的
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
''''----加这句
set rs=nothing
'''写入另一个表.
set rs2=server.CreateObject ("adodb.recordset")
userpath=fullpath&username
sql="select * from [choice]"
rs2.open sql,conn,1,3
rs2.addnew
'''------------------------------------
''以下的是你原来的,你要不要.不要就删除了.
rs2("username")=username
rs2("password")=password
rs2("email")=email
rs2("Tel")=Tel
rs2("sitetype")=sitetype
rs2("AccountPlace")=AccountPlace
rs2("Usertype")=Usertype
''''--------------------------------------
''-----------------------------
''''以下的是你加上的.
''''首先你的这个表要有字段times,profession,income,才可以写入啊.
rs("times")=times
rs2("profession")=profession
rs2("income")=income
rs2.update
''---打完收工.如果你还要操作,也可先不收工.
set rs2=nothing
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Set fso = Server.CreateObject("Scripting.FileSystemObject")
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
rs.close
sql="select * from [choice]"
rs.open sql,conn,1,3
rs.addnew
rs("time")=time
rs("profession")=profession
rs("income")=income
rs("username")=username '最好有这一句,数据库里也加上这个字段,要不两个表的记录没有对应关系了。
rs.update
rs.close
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
rs.close
sql="select * from [choice]"
rs.open sql,conn,1,3
rs.addnew
rs("time")=time
rs("profession")=profession
rs("income")=income
rs("username")=username '最好有这一句,数据库里也加上这个字段,要不两个表的记录没有对应关系了。
rs.update
rs.close
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
很简单啊,choice表和user是不是相同字段,如果相同,就在代码后面加上这个.
time=htmlEncode2(request.form("time"))
profession=htmlEncode2(request.form("profession"))
income=htmlEncode2(request.form("income"))
sql2="select * from [choice]"
rs2.open sql2,conn,1,3
rs.addnew
rs("time")=time
rs("profession")=profession
rs("income")=income
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
time=htmlEncode2(request.form("time"))
profession=htmlEncode2(request.form("profession"))
income=htmlEncode2(request.form("income"))
sql2="select * from [choice]"
rs2.open sql2,conn,1,3
rs.addnew
rs("time")=time
rs("profession")=profession
rs("income")=income
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
很简单,改为以下代码:
Set fso = Server.CreateObject("Scripting.FileSystemObject")
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
conn.execute"insert into choice(time,profession,income)values('"&request("time")&"','"&request("profession")&"','"&request("income")&"')"
这样就可以了
Set fso = Server.CreateObject("Scripting.FileSystemObject")
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
conn.execute"insert into choice(time,profession,income)values('"&request("time")&"','"&request("profession")&"','"&request("income")&"')"
这样就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
username=htmlEncode2(request.form("username"))
password=htmlEncode2(request.form("password"))
email=htmlEncode2(request.form("email"))
Tel=htmlEncode2(request.form("Tel"))
AccountPlace=htmlEncode2(request.form("AccountPlace"))
Usertype=htmlEncode2(request.form("Usertype"))
Set fso = Server.CreateObject("Scripting.FileSystemObject")
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
time=htmlEncode2(request("time"))
profession=htmlEncode2(request("profession"))
income=htmlEncode2(request("income"))
sql="select * from [choice]"
rs.open sql,conn,1,3
rs.addnew
rs("time")=time
rs("profession")=profession
rs("income")=income
rs.update
password=htmlEncode2(request.form("password"))
email=htmlEncode2(request.form("email"))
Tel=htmlEncode2(request.form("Tel"))
AccountPlace=htmlEncode2(request.form("AccountPlace"))
Usertype=htmlEncode2(request.form("Usertype"))
Set fso = Server.CreateObject("Scripting.FileSystemObject")
userpath=fullpath&username
sql="select * from [user]"
rs.open sql,conn,1,3
rs.addnew
rs("username")=username
rs("password")=password
rs("email")=email
rs("Tel")=Tel
rs("sitetype")=sitetype
rs("AccountPlace")=AccountPlace
rs("Usertype")=Usertype
rs.update
time=htmlEncode2(request("time"))
profession=htmlEncode2(request("profession"))
income=htmlEncode2(request("income"))
sql="select * from [choice]"
rs.open sql,conn,1,3
rs.addnew
rs("time")=time
rs("profession")=profession
rs("income")=income
rs.update
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询