谁有时间帮我解决问题下,很急 很急 ~!!分分分!!!

netajax1 2010-01-20 01:57:43
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

提供的用户名无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Web.Security.MembershipCreateUserException: 提供的用户名无效。

源错误:


行 52: string email = txtEmail.ValidationGroup.ClearHtml().Trim();
行 53:
行 54: MembershipUser Result = System.Web.Security.Membership.CreateUser(memberName, passWord, email);// "", "", true, out state);
行 55:
行 56: PersonalInfo user = new PersonalInfo();





谁有时间帮我解决这个问题,通过QQ远程,鄙人的QQ:464301048
纠结了几天了,就是一个注册功能,只需要插入“用户名,密码,Email” 。但是,有三个表与之关联 ,先得往另外两个表里面插入数据之后,才能到第三个表里面

...全文
323 16 打赏 收藏 举报
写回复
16 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
netajax1 2010-01-20
  • 打赏
  • 举报
回复
4 楼大哥 、、一句话
非常感谢,多谢

也多谢给位给小弟的默默支持 多谢了
草根醉秋意 2010-01-20
  • 打赏
  • 举报
回复
netajax1 2010-01-20
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 netajax1 的回复:]
按照 4 楼 给的代码
我试了下。


“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

如果使用没有提供选项值的 SqlDependency,必须先调用 SqlDependency.Start(),然后才能执行添加到 SqlDependency 实例中的命令。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.InvalidOperationException: 如果使用没有提供选项值的 SqlDependency,必须先调用 SqlDependency.Start(),然后才能执行添加到 SqlDependency 实例中的命令。

源错误:


行 143: dc.Refresh(RefreshMode.OverwriteCurrentValues, queryable);
行 144: // 8. 執行 SqlCacheDepency 查詢
行 145: cmd.ExecuteNonQuery();
行 146: // 9. 執行 LINQ to SQL 的查詢,並將結果轉成 IQueryable <T> 型別,避免延遲查詢(Delayed Query)立即將資料取回
行 147: objCache = queryable.ToList();

报错
[/Quote]



非常对不起 4 楼 的大哥,是我自己不小心给搞错了
4 楼 的大哥,对不起 ——!不知道怎么称呼,以后就称为 4楼的大哥吧
netajax 2010-01-20
  • 打赏
  • 举报
回复
再次希望更多人看到
云中雁荡山 2010-01-20
  • 打赏
  • 举报
回复
关注一下
netajax1 2010-01-20
  • 打赏
  • 举报
回复
按照 4 楼 给的代码
我试了下。


“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

如果使用没有提供选项值的 SqlDependency,必须先调用 SqlDependency.Start(),然后才能执行添加到 SqlDependency 实例中的命令。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.InvalidOperationException: 如果使用没有提供选项值的 SqlDependency,必须先调用 SqlDependency.Start(),然后才能执行添加到 SqlDependency 实例中的命令。

源错误:


行 143: dc.Refresh(RefreshMode.OverwriteCurrentValues, queryable);
行 144: // 8. 執行 SqlCacheDepency 查詢
行 145: cmd.ExecuteNonQuery();
行 146: // 9. 執行 LINQ to SQL 的查詢,並將結果轉成 IQueryable<T> 型別,避免延遲查詢(Delayed Query)立即將資料取回
行 147: objCache = queryable.ToList();

报错
netajax1 2010-01-20
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 javak 的回复:]
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<script runat="server">

public void CreateUser_OnClick(object sender, EventArgs args)
{
  MembershipCreateStatus result;

  try
  {
    // Create new user.

    if (Membership.RequiresQuestionAndAnswer)
    {
      MembershipUser newUser = Membership.CreateUser(
        UsernameTextbox.Text,
        PasswordTextbox.Text,
        EmailTextbox.Text,
        PasswordQuestionTextbox.Text,
        PasswordAnswerTextbox.Text,
        false,
        out result);
    }
    else
    {
      MembershipUser newUser = Membership.CreateUser(
        UsernameTextbox.Text,
        PasswordTextbox.Text,
        EmailTextbox.Text);
    }

    Response.Redirect("login.aspx");
  }
  catch (MembershipCreateUserException e)
  {
    Msg.Text = GetErrorMessage(e.StatusCode);
  }
  catch (HttpException e)
  {
    Msg.Text = e.Message;
  }
}

public string GetErrorMessage(MembershipCreateStatus status)
{
  switch (status)
  {
      case MembershipCreateStatus.DuplicateUserName:
        return "Username already exists. Please enter a different user name.";

      case MembershipCreateStatus.DuplicateEmail:
        return "A username for that e-mail address already exists. Please enter a different e-mail address.";

      case MembershipCreateStatus.InvalidPassword:
        return "The password provided is invalid. Please enter a valid password value.";

      case MembershipCreateStatus.InvalidEmail:
        return "The e-mail address provided is invalid. Please check the value and try again.";

      case MembershipCreateStatus.InvalidAnswer:
        return "The password retrieval answer provided is invalid. Please check the value and try again.";

      case MembershipCreateStatus.InvalidQuestion:
        return "The password retrieval question provided is invalid. Please check the value and try again.";

      case MembershipCreateStatus.InvalidUserName:
        return "The user name provided is invalid. Please check the value and try again.";

      case MembershipCreateStatus.ProviderError:
        return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

      case MembershipCreateStatus.UserRejected:
        return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

      default:
        return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
  }
}

</script>

<html>
<head>
<title>Create User </title>
</head>
<body>

<form runat="server">
  <h3>Create New User </h3>

  <asp:Label id="Msg" ForeColor="maroon" runat="server" /> <BR>

  <table CellPadding="3" border="0">
    <tr>
      <td>Username: </td>
      <td> <asp:Textbox id="UsernameTextbox" runat="server" /> </td>
      <td> <asp:RequiredFieldValidator id="UsernameRequiredValidator" runat="server"
                                      ControlToValidate="UserNameTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /> </td>
    </tr>
    <tr>
      <td>Password: </td>
      <td> <asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /> </td>
      <td> <asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
                                      ControlToValidate="PasswordTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /> </td>
    </tr>
    <tr>
      <td>Confirm Password: </td>
      <td> <asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /> </td>
      <td> <asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
                                      ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" />
          <asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
                                      ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
                                      Display="Static" ControlToCompare="PasswordTextBox"
                                      ErrorMessage="Confirm password must match password." />
      </td>
    </tr>
    <tr>
      <td>Email Address: </td>
      <td> <asp:Textbox id="EmailTextbox" runat="server" /> </td>
      <td> <asp:RequiredFieldValidator id="EmailRequiredValidator" runat="server"
                                      ControlToValidate="EmailTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /> </td>
    </tr>


<% if (Membership.RequiresQuestionAndAnswer) { %>

    <tr>
      <td>Password Question: </td>
      <td> <asp:Textbox id="PasswordQuestionTextbox" runat="server" /> </td>
      <td> <asp:RequiredFieldValidator id="PasswordQuestionRequiredValidator" runat="server"
                                      ControlToValidate="PasswordQuestionTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /> </td>
    </tr>
    <tr>
      <td>Password Answer: </td>
      <td> <asp:Textbox id="PasswordAnswerTextbox" runat="server" /> </td>
      <td> <asp:RequiredFieldValidator id="PasswordAnswerRequiredValidator" runat="server"
                                      ControlToValidate="PasswordAnswerTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /> </td>
    </tr>

<% } %>


    <tr>
      <td> </td>
      <td> <asp:Button id="CreateUserButton" Text="Create User" OnClick="CreateUser_OnClick" runat="server" /> </td>
    </tr>
  </table>
</form>

</body>
</html>
[/Quote]

能帮忙给我远程解决下麽, 主要是三个表关联 不知道怎么弄
netajax1 2010-01-20
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 itliyi 的回复:]
友情up
[/Quote]

多谢 多谢
netajax 2010-01-20
  • 打赏
  • 举报
回复
希望更多人看到.
netajax 2010-01-20
  • 打赏
  • 举报
回复
希望更多人看到.
netajax 2010-01-20
  • 打赏
  • 举报
回复
希望更多人看到.
itliyi 2010-01-20
  • 打赏
  • 举报
回复
友情up
JavaK 2010-01-20
  • 打赏
  • 举报
回复
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<script runat="server">

public void CreateUser_OnClick(object sender, EventArgs args)
{
MembershipCreateStatus result;

try
{
// Create new user.

if (Membership.RequiresQuestionAndAnswer)
{
MembershipUser newUser = Membership.CreateUser(
UsernameTextbox.Text,
PasswordTextbox.Text,
EmailTextbox.Text,
PasswordQuestionTextbox.Text,
PasswordAnswerTextbox.Text,
false,
out result);
}
else
{
MembershipUser newUser = Membership.CreateUser(
UsernameTextbox.Text,
PasswordTextbox.Text,
EmailTextbox.Text);
}

Response.Redirect("login.aspx");
}
catch (MembershipCreateUserException e)
{
Msg.Text = GetErrorMessage(e.StatusCode);
}
catch (HttpException e)
{
Msg.Text = e.Message;
}
}

public string GetErrorMessage(MembershipCreateStatus status)
{
switch (status)
{
case MembershipCreateStatus.DuplicateUserName:
return "Username already exists. Please enter a different user name.";

case MembershipCreateStatus.DuplicateEmail:
return "A username for that e-mail address already exists. Please enter a different e-mail address.";

case MembershipCreateStatus.InvalidPassword:
return "The password provided is invalid. Please enter a valid password value.";

case MembershipCreateStatus.InvalidEmail:
return "The e-mail address provided is invalid. Please check the value and try again.";

case MembershipCreateStatus.InvalidAnswer:
return "The password retrieval answer provided is invalid. Please check the value and try again.";

case MembershipCreateStatus.InvalidQuestion:
return "The password retrieval question provided is invalid. Please check the value and try again.";

case MembershipCreateStatus.InvalidUserName:
return "The user name provided is invalid. Please check the value and try again.";

case MembershipCreateStatus.ProviderError:
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}

</script>

<html>
<head>
<title>Create User</title>
</head>
<body>

<form runat="server">
<h3>Create New User</h3>

<asp:Label id="Msg" ForeColor="maroon" runat="server" /><BR>

<table CellPadding="3" border="0">
<tr>
<td>Username:</td>
<td><asp:Textbox id="UsernameTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="UsernameRequiredValidator" runat="server"
ControlToValidate="UserNameTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
ControlToValidate="PasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" />
<asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ControlToCompare="PasswordTextBox"
ErrorMessage="Confirm password must match password." />
</td>
</tr>
<tr>
<td>Email Address:</td>
<td><asp:Textbox id="EmailTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="EmailRequiredValidator" runat="server"
ControlToValidate="EmailTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>


<% if (Membership.RequiresQuestionAndAnswer) { %>

<tr>
<td>Password Question:</td>
<td><asp:Textbox id="PasswordQuestionTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordQuestionRequiredValidator" runat="server"
ControlToValidate="PasswordQuestionTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password Answer:</td>
<td><asp:Textbox id="PasswordAnswerTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordAnswerRequiredValidator" runat="server"
ControlToValidate="PasswordAnswerTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>

<% } %>


<tr>
<td></td>
<td><asp:Button id="CreateUserButton" Text="Create User" OnClick="CreateUser_OnClick" runat="server" /></td>
</tr>
</table>
</form>

</body>
</html>
netajax1 2010-01-20
  • 打赏
  • 举报
回复
PersonalInfo user = new PersonalInfo();
user.Name = txtName.Text;
user.HPNumber = txtPassword.Text;
user.Email = txtEmail.Text;
//PersonalInfo.AddUser(user);

if (!BLL.AddUser(user))
{
Response.Write("<script>alert('对不起,注册失败,请您稍后再试!');</script>");
}
else
{
Session[""] = user;
PersonalInfo.UpdateUserloginTime(user);
System.Web.Security.FormsAuthentication.SetAuthCookie(user.UserID.ToString(), true);
Response.Redirect("~/MemberShip/individual.aspx");
}

本来只有这一段的,报的错误是 数据里面 有冲突
netajax1 2010-01-20
  • 打赏
  • 举报
回复
protected void btnRegister_Click(object sender, EventArgs e)
{
//if (getMainPlayDirection()[1].Trim().ClearHtml().Length == 0 || ddlProvices.SelectedValue == "所有省份" || ddlcity.SelectedValue == "所有城市" || ddlMainIndustry.SelectedValue == "主营行业") { Page.ClientScript.RegisterStartupScript(this.GetType(), "registererror", "<script>alert('对不起,由于发生了错误,注册不成功。')</script>"); return; }

string memberName = txtName.ValidationGroup.ClearHtml().Trim();
string passWord = txtPassword.ValidationGroup.ClearHtml().Trim();
string email = txtEmail.ValidationGroup.ClearHtml().Trim();

MembershipUser Result = System.Web.Security.Membership.CreateUser(memberName, passWord, email);// "", "", true, out state);

PersonalInfo user = new PersonalInfo();
user.Name = txtName.Text;
user.HPNumber = txtPassword.Text;
user.Email = txtEmail.Text;
//PersonalInfo.AddUser(user);

if (!BLL.AddUser(user))
{
Response.Write("<script>alert('对不起,注册失败,请您稍后再试!');</script>");
}
else
{
Session[""] = user;
PersonalInfo.UpdateUserloginTime(user);
System.Web.Security.FormsAuthentication.SetAuthCookie(user.UserID.ToString(), true);
Response.Redirect("~/MemberShip/individual.aspx");
}
}

注册按钮下面的代码、、、、、
netajax1 2010-01-20
  • 打赏
  • 举报
回复
\4.jpg
发帖
JavaScript

8.7w+

社区成员

Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
帖子事件
创建了帖子
2010-01-20 01:57
社区公告
暂无公告