Page 1 of 1

Can't add a user in ASP.Net

Posted: Mon Feb 16, 2009 12:12 pm
by Vnsmith5
I'm having a problem adding a user in ASP.Net, but outside of ablecommerce.
here's the code below:
Try
Dim jonesy As New System.Web.Security.MembershipCreateStatus
Dim newUser As User = UserDataSource.CreateUser(txtUserName.Text.Trim, txtPassword.Text.Trim, String.Empty, String.Empty, True, 0, jonesy)
Dim newuserGroup As New UserGroup(newUser.UserId, 10)
newUser.UserGroups.Add(newuserGroup)
newUser.IsApproved = True
newUser.Save()

If jonesy = Security.MembershipCreateStatus.Success Then
lblResult.Text = "User was successfully created!!!"
Else
lblResult.Text = "Process was unsuccessful! Please try again."
End If
Catch ex As Exception
lblResult.Text = ex.ToString
End Try

When I run this code, I get the following error:
System.NullReferenceException: Object reference not set to an instance of an object.
at CommerceBuilder.Configuration.TokenBase..ctor()
at CommerceBuilder.Common.Token..ctor()
at CommerceBuilder.Common.Token.get_Instance()
at CommerceBuilder.Users.UserDataSource.CreateUser(String email, String password, String passwordQuestion, String passwordAnswer, Boolean isApproved, Int32 affiliateId, MembershipCreateStatus& status)
at StorePasswordTest.Form1.Button1_Click(Object sender, EventArgs e) in C:\ProgTest\StorePasswordTest\StorePasswordTest\Form1.vb:line 48


any ideas?

Re: Can't add a user in ASP.Net

Posted: Mon Feb 16, 2009 2:44 pm
by Carolharry
Try removing
dim jonesy as new MembershipCreateStatus
to
dim jonesy as MembershipCreateStatus

Thanks
Carol

Re: Can't add a user in ASP.Net

Posted: Mon Feb 16, 2009 3:21 pm
by Vnsmith5
I tried that, and I still get the same message.
I think it's in the CreateUser line, but I can't find a solution.

Thanks for trying though!

Re: Can't add a user in ASP.Net

Posted: Wed Feb 18, 2009 11:13 am
by Vnsmith5
is there any other way to import users quickly into the AbleCommerce database?
Since, I can't figure out why I'm getting the above error, I'll need a new way to get the process done.

I'd like to be able to do it in VB.Net if at all possible.

Re: Can't add a user in ASP.Net

Posted: Wed Feb 18, 2009 11:17 am
by mazhar
You can use DataPort tool to import users.
http://wiki.ablecommerce.com/index.php/ ... rt_Utility