Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Createuser exception handling

Reply
Thread Tools

Createuser exception handling

 
 
John
Guest
Posts: n/a
 
      08-27-2006
Hi

I am using the membership createuser method but need to find the error when
one arise. I am using the below code;

Public Function CreateUser(ByVal Username As String, ByVal Password As
String, ByVal Email As String, ByRef ErrMsg As String) As Boolean
Try
Membership.CreateUser(Username, Password, Email)
CreateUser = True
Catch ex As MembershipCreateUserException
ErrMsg = ex.StatusCode
CreateUser = False
End Try
End Function

The problem is that as far as I can tell the ErrMsg always returns blank.
What am I doing wrong?

Thanks

Regards


 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      08-28-2006
Hi John,

You'll want to use one of the overloads to get the information you seek. It
comes back in a MembershipCreateStatus value.

Check the code below and see if it gives you an idea?

Ken
Microsoft MVP [ASP.NET]


<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim status As MembershipCreateStatus
Dim usr As MembershipUser
usr = Membership.CreateUser("john", "abc123$#!!!", _
"(E-Mail Removed)", _
"Mother's maiden name", "Valerie", _
True, status)
If status = MembershipCreateStatus.Success Then
usr.IsApproved = True
Label1.Text = usr.UserName & " created."
Else
Label1.Text = "There was a problem: " & status.ToString
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:label runat="server" id="Label1"></asp:label>
</div>
</form>
</body>
</html>


"John" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi
>
> I am using the membership createuser method but need to find the error
> when one arise. I am using the below code;
>
> Public Function CreateUser(ByVal Username As String, ByVal Password As
> String, ByVal Email As String, ByRef ErrMsg As String) As Boolean
> Try
> Membership.CreateUser(Username, Password, Email)
> CreateUser = True
> Catch ex As MembershipCreateUserException
> ErrMsg = ex.StatusCode
> CreateUser = False
> End Try
> End Function
>
> The problem is that as far as I can tell the ErrMsg always returns blank.
> What am I doing wrong?
>
> Thanks
>
> Regards
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Createuser exception handling John ASP .Net Web Services 1 08-28-2006 04:14 AM
Createuser exception handling John ASP .Net Security 1 08-28-2006 01:36 AM
Error: 'CreateUser' is not a member of 'Membership' VB Programmer ASP .Net 3 01-13-2006 05:50 AM
ASP.NET 2.0 Membership CreateUser method =?Utf-8?B?UG9ydG1hbg==?= ASP .Net 0 01-05-2006 05:24 PM
ASP.NET 2.0 Membership.CreateUser problem Joe Gilkey ASP .Net 1 05-12-2005 03:09 AM



Advertisments