0

I am using Altairis security providers for a memebership and roles in my asp.net web application. For registration I use CreateUserWizard. And after the user is created I want to insert his username into another table called Profiles.

       HTML
    ------------
   <asp:CreateUserWizard ID="CreateUserWizard1" OnCreatedUser="CreateUserWizard1_CreatedUser" ....... />
    
    
         VB
    ------------
        Protected Sub CreateUserWizard1_CreatedUser(sender As Object, e As EventArgs)
            'Create profile 
            Dim connStr As String = System.Configuration.ConfigurationManager.ConnectionStrings("DeskriptivaConnectionString").ConnectionString.ToString()
            
            Using conn As New SqlConnection(connStr)
                Try
                    Dim cmd As SqlCommand = conn.CreateCommand()
                    cmd.CommandText = "INSERT INTO Profiles (UserName) VALUES (@UserName)"
                    cmd.Parameters.Add("@UserName", System.Data.SqlDbType.NVarChar).Value = CreateUserWizard1.UserName
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            End Using
        End Sub

But when the registration is complete the username doesnt insert into the Profiles table and no error message display. What should I do to make it working?

1 Answer 1

1

You never execute the command. Try cmd.ExecuteNonQuery() after adding the parameter

If you need more info look here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.