我正在使用Altairis 安全提供程序作为我的 asp.net Web 应用程序中的成员和角色。对于注册,我使用 CreateUserWizard。创建用户后,我想将他的用户名插入另一个名为 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
但是当注册完成时,用户名不会插入到 Profiles 表中,也不会显示错误消息。我应该怎么做才能让它工作?