3.注册页面后台代码using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CCE.Components;namespace cce.Users
{
/// <summary>
/// register 的摘要说明。
/// </summary>
public class register : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel panel1;

protected System.Web.UI.WebControls.Panel panel6; private const string ClientScriptID = "{AE25F91D-E68A-4de2-BAB4-FA6EE6A17B4E}";
protected System.Web.UI.WebControls.TextBox UserName;
protected System.Web.UI.WebControls.TextBox Password;
protected System.Web.UI.WebControls.TextBox ConfirmPass;
protected System.Web.UI.WebControls.TextBox TrueName;
protected System.Web.UI.WebControls.TextBox NickName;
protected System.Web.UI.WebControls.TextBox Email;
protected System.Web.UI.WebControls.Button RegisterAddBtn;
protected System.Web.UI.WebControls.Label Message;
protected System.Web.UI.WebControls.RequiredFieldValidator required_UserName;
protected System.Web.UI.WebControls.RegularExpressionValidator regular_UserName;
protected System.Web.UI.WebControls.DataList FAQList; protected SecureDBConnection dbConn = new SecureDBConnection();

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{

panel1.Visible = true;
BindDataFAQ();
}

} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load); }
#endregion protected void RegisterAddBtn_Click(object sender, System.EventArgs e)
{
if(ValidateRegister())
{
try 
{
SqlCommand myCommand = new SqlCommand("Users_Create", dbConn.Connect());
myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add(new SqlParameter("@Action", SqlDbType.Int));
myCommand.Parameters["@Action"].Value = 0; myCommand.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 64));
myCommand.Parameters["@UserName"].Value = UserName.Text.Trim(); myCommand.Parameters.Add(new SqlParameter("@TrueName", SqlDbType.NVarChar, 64));
myCommand.Parameters["@TrueName"].Value = TrueName.Text.Trim(); myCommand.Parameters.Add(new SqlParameter("@NickName", SqlDbType.NVarChar, 64));
myCommand.Parameters["@NickName"].Value = NickName.Text.Trim(); myCommand.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 32));
myCommand.Parameters["@Password"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Text,"MD5"); // 允许为空字段 begin
myCommand.Parameters.Add(new SqlParameter("@PersonalEmail", SqlDbType.VarChar, 128));
myCommand.Parameters["@PersonalEmail"].Value = Email.Text.Trim();
// 允许为空字段 end

SqlParameter pUserID = new SqlParameter("@UserID", SqlDbType.BigInt);
pUserID.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(pUserID); // 存储过程返回值
SqlParameter pRtnValue = new SqlParameter("rtnValue", SqlDbType.Int);
pRtnValue.Direction = ParameterDirection.ReturnValue;
myCommand.Parameters.Add(pRtnValue); myCommand.ExecuteNonQuery(); switch (Int32.Parse(pRtnValue.Value.ToString()))
{
case 0:

panel1.Visible = false;
panel6.Visible = true;
// execClientScript("注册成功!");
break;
case 1:
execClientScript("用户名 "+UserName.Text.Trim()+" 已注册,请重新输入!");
break;
case 2:
execClientScript("Email地址 "+Email.Text.Trim()+" 已注册,请重新输入!");
break;
case 3:
execClientScript("昵称 "+NickName.Text.Trim()+" 已注册,请重新输入!");
break;
}
}
catch {}
finally { dbConn.DisConnect();}
}
}
private bool ValidateRegister()
{
if(Password.Text == "" || ConfirmPass.Text == "")
{
Message.Text = "[密码和确认密码栏不能为空]";
return false;
}
else if(Password.Text != ConfirmPass.Text)
{
Message.Text = "[两次密码输入不一致]";
return false;
}
else if(TrueName.Text.Trim() == "")
{
Message.Text = "[姓名不能为空]";
return false;
}
else if(NickName.Text.Trim() == "")
{
Message.Text = "[昵称不能为空]";
return false;
}
return true;
}
#region Button事件逻辑




protected void RegisterSubmitBtn_Click(object sender, System.EventArgs e)
{
Response.Redirect("../member.aspx");
}
#endregion
private void BindDataFAQ()
{
try
{
SqlDataAdapter myCommand = new SqlDataAdapter("GetActions1", dbConn.Connect());
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Action", SqlDbType.Int));
myCommand.SelectCommand.Parameters["@Action"].Value = 3; DataSet ds = new DataSet();
myCommand.Fill(ds, "FAQList");
FAQList.DataSource = ds.Tables["FAQList"].DefaultView;
FAQList.DataBind();
}
catch {}
finally { dbConn.DisConnect();}
}
private void execClientScript(string text)
{
string script;
script = "<script language='JavaScript'>\n";
script += "alert('" + text + "');\n<";
script += "/script>";
if(!Page.IsStartupScriptRegistered(ClientScriptID))
Page.RegisterStartupScript(ClientScriptID,script);
}
}
}
问题:无任何提示信息,数据库无插入!
已经确定问题出现在存储过程里,可我怎么都找不到出现问题的所在.谁能帮我看看.
我是新手

解决方案 »

  1.   

    4.注册页面html代码:
    <%@ Page language="c#" Codebehind="register.aspx.cs" AutoEventWireup="false" Inherits="cce.Users.register" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>
    <%=ConfigurationSettings.AppSettings["SiteName"]%>
    </title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <LINK href="../Themes/default/style/default.css" type="text/css" rel="stylesheet">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <table cellSpacing="0" cellPadding="0" width="760" align="center" bgColor="#ffffff" border="0">
    <TBODY>
    <tr>
    <td vAlign="top" width="188">
    <table class="font" height="24" cellSpacing="0" cellPadding="0" width="100%" border="0">
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td width="20" bgColor="#d0b29a">
    </td>
    <td bgColor="#d0b29a"><strong></strong></td>
    </tr>
    </table>
    <table class="font" cellSpacing="1" cellPadding="0" width="100%" border="0">
    <tr>
    <td colSpan="2" height="1"><IMG height="1" src="images/spacer.gif"></td>
    </tr>
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td bgColor="#fff1e6" height="22">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td bgColor="#fff1e6" height="22">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td bgColor="#fff1e6" height="22">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td bgColor="#fff1e6" height="22">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td bgColor="#fff1e6" height="22">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td bgColor="#fff1e6" height="22">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td bgColor="#fff1e6" height="22">&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td colSpan="2" height="1"><IMG height="1" src="images/spacer.gif"></td>
    </tr>
    </table>
    <table class="font" height="24" cellSpacing="0" cellPadding="0" width="100%" border="0">
    <tr>
    <td width="5" bgColor="#720000">
    </td>
    <td width="20" bgColor="#d0b29a">
    </td>
    <td bgColor="#d0b29a"><strong></strong></td>
    </tr>
    </table>
    <table width="100%" border="0" cellPadding="0" cellSpacing="0" class="font2">
    <TBODY>
    <tr>
    <td width="100%" colspan="2"></td>
    </tr>
    <tr>
    <td height="25">
    </td>
    <td>
    <div align="right">&nbsp;&nbsp;</div>
    </td>
    </tr>
    </TBODY>
    </table>
    <asp:DataList id="FAQList" runat="server"></asp:DataList>
    </td>
    <td width="12">
    </td>
    <td vAlign="top" width="560">
    <table class="main" height="24" cellSpacing="0" cellPadding="0" width="100%" border="0">
    <tr>
    <td width="21%"><FONT face="宋体"></FONT>
    </td>
    <td width="79%">
    <div align="right">:&nbsp;</div>
    </td>
    </tr>
    </table>
    <table cellSpacing="0" cellPadding="0" width="100%" border="0">
    <tr>
    <td width="27%" bgColor="#990000" height="3"><IMG height="3" src="images/spacer.gif" width="1"></td>
    <td width="73%" bgColor="#d0b29a" height="3"><IMG height="3" src="images/spacer.gif" width="1"></td>
    </tr>
    </table>
    <asp:panel id="panel1" Runat="server" Visible="False">
    <TABLE cellSpacing="5" cellPadding="0" width="100%" border="0">
    <TR>
    <TD>
    <DIV align="center">
    <TABLE class="main" cellSpacing="8" cellPadding="0" width="90%" border="0">
    <TR>
    <TD colSpan="2"><FONT color="#990000"><STRONG>填写个人信息</STRONG></FONT></TD>
    </TR>
    <TR>
    <TD colSpan="2">&nbsp;&nbsp;&nbsp;&nbsp;请准确填写您的个人信息(加<FONT color="#ff0000">*</FONT>号的栏目为必填部分)。<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;</TD>
    </TR>
    <TR>
    <TD width="21%">
    <DIV align="right"><FONT color="#000000">用户名:</FONT></DIV>
    </TD>
    <TD width="79%">
    <asp:TextBox id="UserName" Runat="server" Text="" TextMode="SingleLine" Width="150"></asp:TextBox><FONT color="#ff0000">*</FONT>
    用户登陆使用
    </TD>
    </TR>
    <TR>
    <TD>
    <DIV align="right"><FONT color="#000000">密&nbsp;&nbsp;码:</FONT></DIV>
    </TD>
    <TD><FONT color="#ff0000">
    <asp:TextBox id="Password" Runat="server" Text="" TextMode="Password" Width="150"></asp:TextBox>*
    </FONT>
    </TD>
    </TR>
    <TR>
    <TD>
    <DIV align="right"><FONT color="#000000">确认密码:</FONT></DIV>
    </TD>
    <TD><FONT color="#ff0000">
    <asp:TextBox id="ConfirmPass" Runat="server" Text="" TextMode="Password" Width="150"></asp:TextBox>*
    </FONT>
    </TD>
    </TR>
    <TR>
    <TD>
    <DIV align="right"><FONT color="#000000">姓名:</FONT></DIV>
    </TD>
    <TD><FONT color="#ff0000">
    <asp:TextBox id="TrueName" Runat="server" Text="" TextMode="SingleLine" Width="150" Height="20"></asp:TextBox>*
    </FONT>
    </TD>
    </TR>
    <TR>
    <TD>
    <DIV align="right"><FONT color="#000000">昵称:</FONT></DIV>
    </TD>
    <TD><FONT color="#ff0000">
    <asp:TextBox id="NickName" Runat="server" Text="" TextMode="SingleLine" Width="150"></asp:TextBox>*
    </FONT>您的论坛ID</TD>
    </TR>
    <TR>
    <TD>
    <DIV align="right"><FONT color="#000000">电子邮件:</FONT></DIV>
    </TD>
    <TD>
    <asp:TextBox id="Email" Runat="server" Text="" TextMode="SingleLine" Width="150"></asp:TextBox></TD>
    </TR>
    <TR>
    <TD style="COLOR: red" colSpan="2">
    <asp:RequiredFieldValidator id="required_UserName" runat="server" ControlToValidate="UserName" Display="Dynamic">
    [用户名不能为空]
    </asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator id="regular_UserName" runat="server" ControlToValidate="UserName" Display="Dynamic"
    ValidationExpression=".{2,}">
    [用户名必须两位或两位以上]
    </asp:RegularExpressionValidator>
      

  2.   

    <asp:Label id="Message" Runat="server" EnableViewState="False"></asp:Label></TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    <TD>
    <asp:Button id="RegisterAddBtn" onclick="RegisterAddBtn_Click" Runat="server" Text="提 交"></asp:Button>&nbsp;&nbsp;
    <INPUT id="Reset" type="reset" value="重 置" name="Reset">
    </TD>
    </TR>
    </TABLE>
    </DIV>
    </TD>
    </TR>
    </TABLE>
    </asp:panel>
    </form>
    <asp:panel id="panel6" Runat="server" Visible="False">
    <TABLE width="100%" align="center">
    <TR>
    <TD colSpan="2">&nbsp;</TD>
    </TR>
    <TR>
    <TD colSpan="2">&nbsp;</TD>
    </TR>
    <TR>
    <TD width="100">&nbsp;</TD>
    <TD style="FONT-WEIGHT: bold; COLOR: #ff0000">注册成功!
    </TD>
    </TR>
    <TR>
    <TD colSpan="2">&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    <TD><STRONG></STRONG></TD>
    </TR>
    <TR>
    <TD colSpan="2">&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD colSpan="2">&nbsp;</TD>
    </TR>
    </TABLE>
    </asp:panel></TD></TR></TBODY></TABLE></FORM>
    </body>
    </HTML>
      

  3.   

    太长了 好吓人哦 我记得我当时玩ASP.NET的时候 着个功能连100行都不到啊
      

  4.   

    主要是html的长了点!代码还好的~
    帮我看看存储过程,和代码!
    我可以肯定是存储过程的问题
      

  5.   

    好像没这么复杂吧!!
      下个微软的SQLHelper的类,几句话就可以搞定了!
    好比登录就是:string   str="数据库链接";
                  obecjt obj=SqlHelper.ExectuCalar(str,"存储过程",new object[]{用户名的文本,密码的文本});
                  if(obj>0)
                     登录成功!
                  else
                     登陆失败!
    注册也是类似的~!~
      

  6.   

    我是要让它生成一个复杂的Session,可以根据Session设置员工权限!
    现在我登陆和注册和修改资料都做好了.
    可是现在我的Session的权限不知道该如何设置,我打算做个Session的控件来对每个页面判断Session的权限!
    谁能告诉我,该怎么写?急求原代码!!
      

  7.   

    你很多地方,没用cmd.Parameters.add
      

  8.   

    有些字段是存储过程自动读取写入到数据库的!
    不需要用
    add~~~