asp.net使用求助!紧急求助!

今天老师布置了一个题目:
使用ASP.net制作一个注册页面。主要要求为,使用一个注册页面,然后链接到ACCESS数据库,把用户输入的内容保存到access数据库,这个对于高手是小意思,我是初学者,不懂啊,求救啊!
下面我是做的代码,不知道是哪里错了,调试不行 啊!
其中:数据库在 data 下的050158.mdb 表名是hquser
表中的字段有hq_user、password、sex、age、like、work、qq、email、beizhu、
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" Debug="true" %>


<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>黄青工作室</title>

<script language="c#" runat="server">

 public string like;
 public string sex1;
 public string age1;
 public string qq1;
 public string email1;
 public string beizhu1;
void SubmitBtn_Click(Object Source,EventArgs e)
{
 string username=hq_user.Text;
 string password=passwd.Text;
 if(sex.SelectedIndex>-1)
    {
      sex1="性别:"+sex.SelectedItem.Text;
    }
  age1=age.Text;
  for(int i=0;i<Check1.Items.Count;i++)
      {
          if(Check1.Items[i].Selected)
           {
            like=Check1.Items[i].Text+"&nbsp;";
           }
       }
 string work=DropDown1.SelectedItem.Text;
 qq1=qq.Text;
 email1=email.Text;
 beizhu1=beizhu.Text;
 
  string strConnection="Provider=Microsoft.Jet.Oledb.4.0;Data Source="+Server.MapPath("Data/050158.mdb");
  string queryStr="Select * From hquser where hq_user='"+username+"'";
    OleDbConnection nwConn=new OleDbConnection(strConnection);
  DataSet shipperSet=new DataSet();
  OleDbDataAdapter shipperAdapter=new OleDbDataAdapter(queryStr,nwConn);
   shipperAdapter.Fill(shipperSet,"hquser");
   
    if(shipperSet.Tables["hquser"].Rows.Count!=0)
     {
     Label1.Text="该用户已经存在,请重新输入";
     return;
     }
    queryStr="Select * From hquser";
OleDbDataAdapter shipperAdapters=new OleDbDataAdapter(queryStr,nwConn);
    shipperSet.Clear();
    shipperAdapter.Fill(shipperSet,"hquser");
    DataRow shipperRow=shipperSet.Tables["hquser"].NewRow();
    shipperRow["hq_user"]=username;
    shipperRow["password"]=password;
    shipperRow["sex"]=sex1;
    shipperRow["age"]=age1;
    shipperRow["like"]=like;
    shipperRow["work"]=work;
    shipperRow["qq"]=qq1;
    shipperRow["email"]=email1;
    shipperRow["beizhu"]=beizhu1;
    shipperSet.Tables["hquser"].Rows.Add(shipperRow);
    OleDbCommandBuilder shipperBuilder=new OleDbCommandBuilder(shipperAdapter);
    shipperAdapter.InsertCommand=shipperBuilder.GetInsertCommand();
    shipperAdapter.Update(shipperSet,"hquser");
    shipperSet.Clear();
    shipperAdapter.Fill(shipperSet,"hquser");
   
  shipperGrid.DataSource=shipperSet;
  shipperGrid.DataBind();
}

 
 
</script>

</head>
<body>
<form runat="server">
<asp:DataGrid ID="shipperGrid" runat="server" CellPadding="3" Font-Name="arial" Font-Size="10pt"></asp:DataGrid>
<asp:ValidationSummary ID="valSum" runat="server" HeaderText="你必须在下面空白处填写有效信息:" DisplayMode="BulletList" ShowSummary="false" ShowMessageBox="true" Font-Name="verdana" Font-Size="12"/>
<div align="center">
  <h3>黄青工作室(注册页面)</h3>
</div><br>

<table width="653" height="418" border="1" align="center" bordercolor="#00FF00" bgcolor="#FFFFCC">
  <tr>
    <td width="84" height="33"><div align="center"><font size="2">用户名:</font></div></td>
    <td><asp:TextBox ID="hq_user" Text="" Width="180px" runat="server" TextMode="SingleLine" ToolTip="必须为字母或数字组成" MaxLength="16" />
      <font color="#FF0000">*</font>用户名必须为字母或数字,且必须在3-16位之间
        <asp:RequiredFieldValidator ID="hq_userReqVal" ControlToValidate="hq_user" ErrorMessage="用户名不能为空" Display="Dynamic" Font-Name="Verdana" Font-Size="12" runat="server">用户名不能为空</asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="hq_userRegexVal" ControlToValidate="hq_user" ErrorMessage="用户名格式不正确" Display="Static" ValidationExpression="[/w]{3,16}" Font-Name="Arial" Font-Size="11" Width="100%" runat="server">用户名必须为数字或字母,且必须在3-16位之间</asp:RegularExpressionValidator></td>
 </tr>
  <tr>
    <td height="33"><div align="center"><font size="2">密码:</font></div></td>
    <td><asp:TextBox ID="passwd" TextMode="Password" Width="180px" MaxLength="20" runat="server" ToolTip="密码必须为数字或字母"></asp:TextBox>
      <font color="#FF0000">*</font>密码必须为数字或字母,且必须在6-20位之间
    <asp:RequiredFieldValidator ID="passwdReqVal" ControlToValidate="passwd" ErrorMessage="密码不能为空" Display="Dynamic" Font-Name="Verdana" Font-Size="12" runat="server">密码不能为空</asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="passwdRegexVal" ControlToValidate="passwd" ErrorMessage="Password." Display="Static" ValidationExpression="[/w]{6,20}" Font-Name="Arial" Font-Size="11" Width="100%" runat="server">密码必须为数字或字母,且必须在6-20位之间</asp:RegularExpressionValidator></td>
   </tr>
  <tr>
    <td height="33"><div align="center"><font size="2">确认密码:</font></div></td>
    <td><asp:TextBox ID="passwd1" TextMode="Password" Width="180px" MaxLength="20" runat="server" ToolTip="密码必须为数字或字母"></asp:TextBox>
      <font color="#FF0000">*</font>密码必须为数字或字母,且必须在6-20位之间
    <asp:RequiredFieldValidator ID="passwd2ReqVal" ControlToValidate="passwd1" ErrorMessage="确认密码不能为空" Display="Dynamic" Font-Name="Verdana" Font-Size="12" runat="server">确认密码不能为空</asp:RequiredFieldValidator>
    <asp:CompareValidator ID="CompareValidator1" ControlToValidate="passwd1" ControlToCompare="passwd" ErrorMessage="Re-enter Password." Display="Static" Font-Name="Arial" Font-Size="11" Width="100%" runat="server">两次输入的密码不一样</asp:CompareValidator></td>
   </tr>
  <tr>
    <td height="88"><div align="center"><font size="2">性别:</font></div></td>
    <td><asp:RadiobuttonList ID="sex" runat="server">
<asp:ListItem>boy</asp:ListItem>
<asp:ListItem>girl</asp:ListItem>
</asp:RadiobuttonList>
    <asp:RequiredFieldValidator ID="sexReqVal" ControlToValidate="sex" ErrorMessage="性别不能为空" Display="Dynamic" Font-Name="Verdana" Font-Size="12" runat="server">性别不能为空</asp:RequiredFieldValidator></td>

</td>
  </tr>
  <tr>
    <td height="20"><div align="center"><font size="2">年龄:</font></div></td>
    <td><asp:TextBox ID="age" Text="" Width="180px" runat="server" TextMode="SingleLine" MaxLength="2" ToolTip="年龄必须为数字,且不能超过2个字符" />
      <font color="#FF0000">*</font>如20
    <asp:RequiredFieldValidator ID="ageReqVal" ControlToValidate="age" ErrorMessage="年龄不能为空" Display="Dynamic" Font-Name="Verdana" Font-Size="12" runat="server">年龄不能为空</asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="ageRegexVal" ControlToValidate="age" ErrorMessage="年龄格式不正确" Display="Static" ValidationExpression="[0-9]{2}" Font-Name="Arial" Font-Size="11" Width="100%" runat="server">年龄必须为数字</asp:RegularExpressionValidator></td>
  </tr>
  <tr>
    <td height="75"><div align="center"><font size="2">爱好:</font></div></td>
    <td><asp:CheckBoxList ID="Check1" RepeatDirection="Horizontal" runat="server">
    <asp:ListItem>上网</asp:ListItem>
    <asp:ListItem>旅游</asp:ListItem>
    <asp:ListItem>爬山</asp:ListItem>
    <asp:ListItem>跑步</asp:ListItem>
    <asp:ListItem>足球</asp:ListItem>    
    </asp:CheckBoxList></td>
  </tr>
  <tr>
    <td height="25"><div align="center"><font size="2">职业:</font></div></td>
    <td><asp:DropDownList ID="DropDown1" runat="server">
<asp:ListItem>Teacher</asp:ListItem>
<asp:ListItem>IT</asp:ListItem>
<asp:ListItem>Student</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
</td>
  </tr>
  <tr>
    <td height="20"><div align="center"><font size="2">QQ:</font></div></td>
    <td><asp:TextBox ID="qq" Text="" Width="180px" runat="server" TextMode="SingleLine" ToolTip="QQ必须为数字,不能超过9个字符" MaxLength="9" />
      <font color="#FF0000">*</font>如123456
      <asp:RequiredFieldValidator ID="qqReqVal" ControlToValidate="qq" ErrorMessage="QQ不能为空" Display="Dynamic" Font-Name="Verdana" Font-Size="12" runat="server">QQ不能为空</asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="qqRegexVal" ControlToValidate="qq" ErrorMessage="QQ格式不正确" Display="Static" ValidationExpression="[0-9]{5,9}" Font-Name="Arial" Font-Size="11" Width="100%" runat="server">QQ号码必须为数字,且必须在5-9位</asp:RegularExpressionValidator></td>
   </tr>
  <tr>
    <td height="20"><div align="center"><font size="2">E-Mail:</font></div></td>
    <td><asp:TextBox ID="email" Text="" Width="180px" runat="server" TextMode="SingleLine" />
      <font color="#FF0000">*</font>如abc@abc.com
    <asp:RequiredFieldValidator ID="emailReqVal" ControlToValidate="email" ErrorMessage="Email不能为空" Display="Dynamic" Font-Name="Verdana" Font-Size="12" runat="server">E-mail不能为空</asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="emailRegexVal" ControlToValidate="email" ErrorMessage="Email格式不正确" Display="Static" ValidationExpression="^[/w-]+@[/w-]+/.(com|net|org|edu|mil|cn|com.cn|net.cn|org.cn|gov|gov.cn)$" Font-Name="Arial" Font-Size="11" runat="server">您输入的不是合法的Email地址</asp:RegularExpressionValidator></td>
 </tr>
  <tr>
    <td height="20"><div align="center"><font size="2">备注:</font></div></td>
    <td><asp:TextBox TextMode="MultiLine" Rows="3" Columns="30" ID="beizhu" runat="server"></asp:TextBox></td>
  </tr>
  <tr>
    <td height="25" colspan="2"><asp:Button ID="Button1" Text="确定" OnClick="SubmitBtn_Click" runat="server"></asp:Button></td>
    </tr>
</table>
<asp:Label ID="Label1" Font-Name="Verdana" Font-Size="8pt" runat="server"></asp:Label>

</form>
</body>
</html>
 谁会帮我修改下啊!
我的邮箱是 huangqing316@gmail.com
改後发到我邮箱啊!
感激不尽!
  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值