日期:2014-05-17  浏览次数:20914 次

Asp中如何将表单信息储存到数据库中
要做个学生网上选课系统,在用户注册页面reg.asp,点击提交以后将表单信息提交到regsubmit.asp此页面(我自己写的有错误,真不知道该怎么写了),但是不知道该怎么写代码才能将从reg.asp内的信息存储到数据库中,请高手帮帮忙,把regsubmit.asp正确的代码完整的写出来,让我参考参考阿,谢谢了!
-------数据库中表单信息----------

数据库采用Access2003,数据库中有几个表,其中一个student表内信息
StudentUsename               '登入帐号
StudentPwd                       '登入密码
StudentName                     '用户真实姓名
StudentSex                       '用户性别
StudentTel                       '用户电话
StudentEmail                   '用户邮箱地址
yuanxi                               '用户的院系
zhuanye                             '用户的专业
--------------conn.asp中的内容--------------------

<%
dim   conn
dim   connstr
dim   db
db= "Data/xkxt.mdb "             '数据库文件的位置
Set   conn   =   Server.CreateObject( "ADODB.Connection ")
connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source= "   &   Server.MapPath(db)
conn.Open   connstr

sub   CloseConn()
conn.close
set   conn=nothing
end   sub
%>

------regsubmit.asp中的内容---------
<!--#include   file= "conn.asp "-->
<%
      StudentUsename   =   request.Form( "ID ")
      StudentPwd   =   request.Form( "pwd ")
      StudentName   =   request.Form( "name ")
      StudentSex   =   request.Form( "sex ")
      StudentTel   =   request.Form( "tel ")
      StudentYear   =   request.Form( "year ")
      StudentMonth   =   request.Form( "month ")
      StudentDay   =   request.Form( "day ")
      Yuanxi   =   request.Form( "yuanxi ")
      zhuanye   =   request.Form( "zhuanye ")
      StudentEmail1   =   request.Form( "email1 ")
      StudentEmail2   =   request.Form( "email2 ")
      StudentBirthday   =   StudentYear   &   "- "   &   StudentMonth   &   "- "   &   StudentDay
      StudentEmail   =   StudentEmail1   &   "@ "   &   StudentEmail2
       
set   rs=server.createobject( "adodb.recordset ")
sql= "insert   into   student(StudentUsename,StudentPwd,StudentName,StudentSex,StudentTel,StudentEmail,yuanxi,zhuanye)   values( ' "&StudentUsename& " ', ' "&StudentPwd& " ', ' "&StudentName& " ', ' "&StudentSex& " ', ' "&StudentTel& " ', ' "&StudentEmail& " ', ' "&yuanxi& " &#