DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Create User Wizard

  1. #1
    Join Date
    Feb 2008
    Posts
    12

    Create User Wizard

    Hello friends, i'm using CrateUserwizard in my page for Registration purpose in that i have 3 wizard step i.e. one for login information, second for User personal details and third for email confirmation. My second wizard is used for sending additional user information in the database but when i filling the details and click on next the error occurs.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 47: Dim newUser As MembershipUser = Membership.GetUser(NewUserWizard.UserName)
    Line 48: Dim newUserId As New Guid = DirectCast(newUser.ProviderUserKey, Guid)
    Line 49:
    Line 50:


    i can show you my code behind:

    Code:
    Protected Sub NewUserWizard_ActiveStepChanged(ByVal sender As Object, ByVal e As System.EventArgs) 
    ' Have we JUST reached the Complete step?
    
    NewUserWizard.ActiveStep.Wizard.DisplayCancelButton = False
    
    If NewUserWizard.ActiveStep.Title = "Complete" Then
    
    Dim UserSettings As WizardStep = TryCast(NewUserWizard.FindControl("UserSettings"), WizardStep) 
    ' Programmatically reference the TextBox controls
    
    Dim FirstName As TextBox = TryCast(UserSettings.FindControl("FirstName"), TextBox) 
    Dim LastName As TextBox = TryCast(UserSettings.FindControl("LastName"), TextBox)
    
    Dim Company As TextBox = TryCast(UserSettings.FindControl("Company"), TextBox) 
    Dim Title As TextBox = TryCast(UserSettings.FindControl("Title"), TextBox)
    
    Dim Address1 As TextBox = TryCast(UserSettings.FindControl("Address1"), TextBox) 
    Dim Address2 As TextBox = TryCast(UserSettings.FindControl("Address2"), TextBox)
    
    Dim City As TextBox = TryCast(UserSettings.FindControl("City"), TextBox) 
    Dim Country As DropDownList = TryCast(UserSettings.FindControl("Country"), DropDownList)
    
    Dim Zip As TextBox = TryCast(UserSettings.FindControl("Zip"), TextBox) 
    Dim State As TextBox = TryCast(UserSettings.FindControl("State"), TextBox)
    
    Dim HomeTown As TextBox = TryCast(UserSettings.FindControl("HomeTown"), TextBox) 
    Dim HomepageUrl As TextBox = TryCast(UserSettings.FindControl("HomepageUrl"), TextBox)
    
    Dim Signature As TextBox = TryCast(UserSettings.FindControl("Signature"), TextBox) 
     
    
    ' Update the UserProfiles record for this user
    
    ' Get the UserId of the just-added user
    
    Dim newUser As MembershipUser = Membership.GetUser(NewUserWizard.UserName)Dim newUserId As Guid = DirectCast(newUser.ProviderUserKey, Guid) 
     
    
    ' Insert a new record into UserProfiles
    
    Dim connectionString As String = ConfigurationManager.ConnectionStrings("SecurityTutorialsConnectionString").ConnectionString 
    Dim updateSql As String = "UPDATE UserProfiles SET FirstName = @FirstName, LastName = @LastName, Company = @Company, Title = @Title, Address1 = @Address1, Address2 = @Address2, City = @City, Country = @Country, Zip = @Zip, State = @State, HomeTown = @HomeTown, HomepageUrl = @HomepageUrl, Signature = @Signature WHERE UserId = @UserId"
    
     
    
    Using myConnection As New SqlConnection(connectionString) 
    myConnection.Open()
    
    Dim myCommand As New SqlCommand(updateSql, myConnection) 
    myCommand.Parameters.AddWithValue("@FirstName", FirstName.Text.Trim())
    
    myCommand.Parameters.AddWithValue("@LastName", LastName.Text.Trim()) 
    myCommand.Parameters.AddWithValue("@Company", Company.Text.Trim())
    
    myCommand.Parameters.AddWithValue("@Title", Title.Text.Trim()) 
    myCommand.Parameters.AddWithValue("@Address1", Address1.Text.Trim())
    
    myCommand.Parameters.AddWithValue("@Address2", Address2.Text.Trim()) 
    myCommand.Parameters.AddWithValue("@City", City.Text.Trim())
    
    myCommand.Parameters.AddWithValue("@Country", Country.SelectedValue) 
    myCommand.Parameters.AddWithValue("@Zip", Zip.Text.Trim())
    
    myCommand.Parameters.AddWithValue("@State", State.Text.Trim()) 
    myCommand.Parameters.AddWithValue("@HomeTown", HomeTown.Text.Trim())
    
    myCommand.Parameters.AddWithValue("@HomepageUrl", HomepageUrl.Text.Trim()) 
    myCommand.Parameters.AddWithValue("@Signature", Signature.Text.Trim())
    
    myCommand.Parameters.AddWithValue("@UserId", newUserId) 
    myCommand.ExecuteNonQuery()
    
    myConnection.Close()
    
    End Using
    
    End If
    
    End Sub
    so please help me to solve this matter.

    thank you

  2. #2
    Join Date
    Sep 2008
    Posts
    17
    Quote Originally Posted by saquib189
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 47: Dim newUser As MembershipUser = Membership.GetUser(NewUserWizard.UserName)
    Line 48: Dim newUserId As New Guid = DirectCast(newUser.ProviderUserKey, Guid)
    Line 49:
    Line 50:
    Set a breakpoint on line 47 and have a look at NewUserWizard.UserName. If that looks OK, step to line 48 and have a look at newUser to see if that is null.

    In other words, first find out what the null reference is. Then you can turn your thinkng to why that variable is null when you expected otherwise.

Similar Threads

  1. How to create a user interface
    By Johan Coppens in forum Architecture and Design
    Replies: 1
    Last Post: 08-19-2003, 01:53 AM
  2. I can't create a new user.
    By litqi in forum Enterprise
    Replies: 3
    Last Post: 04-19-2002, 06:45 PM
  3. Wizard .NET Control Released
    By Actipro Software Support in forum dotnet.announcements
    Replies: 0
    Last Post: 02-19-2002, 09:13 PM
  4. Create User Profiles via API
    By Gina Deen in forum VB Classic
    Replies: 0
    Last Post: 12-19-2001, 06:45 AM
  5. Replies: 2
    Last Post: 12-01-2000, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center