Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 16th, 2006, 01:41 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default CreateUserWizard secondary table Return_Value

Hi
Using SQLDataSource and SQL 2005 Stored Procedure I've been successful in creating multiple additional CreateUser fields saving them to "tbl_UserDetails" table.
I pass the UserId to the tbl_UserDetails as well. What I'm struggling with is retreiving the new tbl_UserDetails "Details_Id" (RETURN_VALUE) t-sql RETURN SCOPE_IDENTITY().
I want to integrate it into the Profile data (see SQLDSInsert_Inserting).
I'm not sure if the problem retreiving the RETURN_VALUE is in the SQLDSInsert_Inserting code used or if I'm not addressing the retreival in the "correct" stage of "the Insert process". See below.
Thanks


Imports Telerik.WebControls
Imports SITE.DAL.DBAccess
Imports System.Data
Imports System.Data.SqlClient

Partial Class Site_Pages_Registration
    Inherits System.Web.UI.Page
    Protected WithEvents Update_Date As WebControls.HiddenField

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("Record") IsNot Nothing Then
            CreateUserWizard1.MoveTo(CompleteWizardStep1)
        End If

    End Sub

    Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
        Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)

        If user Is Nothing Then
            Throw New ApplicationException("Can't find the user.")
        End If

        Dim DetailsInsert As SqlDataSource = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("SQLDSInsert"), SqlDataSource)
        Dim UserId As Guid = DirectCast(user.ProviderUserKey, Guid)
        Session("NewUserId") = UserId
        Dim Details_FirstName As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_FirstName"), TextBox)
        Dim Details_LastName As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_LastName"), TextBox)
        Dim Details_MI As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_MI"), TextBox)
        Dim Details_Title As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Title"), TextBox)
        Dim Details_Company As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Company"), TextBox)
        Dim Details_1Comm As Telerik.WebControls.RadMaskedTextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_1Comm"), Telerik.WebControls.RadMaskedTextBox)
        Dim Details_1CommType As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_1CommType"), Telerik.WebControls.RadComboBox)
        Dim Details_2Comm As Telerik.WebControls.RadMaskedTextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_2Comm"), Telerik.WebControls.RadMaskedTextBox)
        Dim Details_2CommType As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_2CommType"), Telerik.WebControls.RadComboBox)
        Dim Details_Address As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Address"), TextBox)
        Dim Details_City As TextBox = CType(CreateUserWizardStep0.ContentTemplateContain er.FindControl("Details_City"), TextBox)
        Dim Details_State As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_State"), Telerik.WebControls.RadComboBox)
        Dim Details_Zip As Telerik.WebControls.RadMaskedTextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Zip"), Telerik.WebControls.RadMaskedTextBox)
        Dim Details_UserTypeId As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_UserTypeId"), Telerik.WebControls.RadComboBox)
        Dim Details_ReceiveEmail As CheckBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_ReceiveEmail"), CheckBox)

        DetailsInsert.Insert()

        Dim UserType As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_UserTypeId"), Telerik.WebControls.RadComboBox)
        Session("UserType") = UserType.SelectedValue.ToString
    End Sub

    Protected Sub SQLDSInsert_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEven tArgs)
        Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)

        e.Command.Parameters("@UserId").Value = user.ProviderUserKey
        e.Command.Parameters("@Details_FirstName").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_FirstName"), TextBox).Text
        e.Command.Parameters("@Details_LastName").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_LastName"), TextBox).Text
        e.Command.Parameters("@Details_MI").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_MI"), TextBox).Text
        e.Command.Parameters("@Details_Company").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Company"), TextBox).Text
        e.Command.Parameters("@Details_Title").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Title"), TextBox).Text
        e.Command.Parameters("@Details_1Comm").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_1Comm"), Telerik.WebControls.RadMaskedTextBox).Text
        e.Command.Parameters("@Details_1CommType").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_1CommType"), Telerik.WebControls.RadComboBox).SelectedValue
        e.Command.Parameters("@Details_2Comm").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_2Comm"), Telerik.WebControls.RadMaskedTextBox).Text
        e.Command.Parameters("@Details_2CommType").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_2CommType"), Telerik.WebControls.RadComboBox).SelectedValue
        e.Command.Parameters("@Details_Address").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Address"), TextBox).Text
        e.Command.Parameters("@Details_City").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_City"), TextBox).Text
        e.Command.Parameters("@Details_State").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_State"), Telerik.WebControls.RadComboBox).SelectedValue
        e.Command.Parameters("@Details_Zip").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Zip"), Telerik.WebControls.RadMaskedTextBox).Text
        e.Command.Parameters("@Details_UserTypeId").Value = Int32.Parse(CType(CreateUserWizard1.CreateUserStep .ContentTemplateContainer.FindControl("Details_Use rTypeId"), Telerik.WebControls.RadComboBox).SelectedValue)
        e.Command.Parameters("@Details_ReceiveEmail").Valu e = CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_ReceiveEmail"), CheckBox).Checked
        e.Command.Parameters("@RETURN_VALUE").Direction = ParameterDirection.ReturnValue
        Dim Record As Integer = e.Command.Parameters("@RETURN_VALUE").Value
        'Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)

        Dim pb As ProfileBase = ProfileBase.Create(user.UserName)
        pb.SetPropertyValue("FirstName", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_FirstName"), TextBox).Text)
        pb.SetPropertyValue("LastName", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_LastName"), TextBox).Text)
        pb.SetPropertyValue("UserName", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("UserName"), TextBox).Text)
        pb.SetPropertyValue("Record", Record.ToString)
        pb.SetPropertyValue("Company", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Company"), TextBox).Text)
        pb.SetPropertyValue("Title", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Title"), TextBox).Text)
        pb.SetPropertyValue("Comm1", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_1Comm"), Telerik.WebControls.RadMaskedTextBox).Text)
        pb.SetPropertyValue("Comm1Type", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_1CommType"), Telerik.WebControls.RadComboBox).SelectedValue)
        pb.SetPropertyValue("Comm2", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_2Comm"), Telerik.WebControls.RadMaskedTextBox).Text)
        pb.SetPropertyValue("Comm2Type", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_2CommType"), Telerik.WebControls.RadComboBox).SelectedValue)
        pb.SetPropertyValue("Address", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Address"), TextBox).Text)
        pb.SetPropertyValue("City", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_City"), TextBox).Text)
        pb.SetPropertyValue("State", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_State"), Telerik.WebControls.RadComboBox).SelectedValue)
        pb.SetPropertyValue("Zip", CType(CreateUserWizard1.CreateUserStep.ContentTemp lateContainer.FindControl("Details_Zip"), Telerik.WebControls.RadMaskedTextBox).Text)

        pb.Save()


    End Sub


    Protected Sub CompleteButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim lblRegisterCompleteName As Label = CreateUserWizard1.CompleteStep.FindControl("lblReg isterCompleteName"), Label
        lblRegisterCompleteName.Text = Profile.FirstName & " " & Profile.LastName
        Dim Muser As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
        If Muser Is Nothing Then
            Throw New ApplicationException("Can't find the user.")
        End If
        Muser.IsApproved = False
    End Sub


    Protected Sub btnTeamProfile_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        'Dim conn As SqlConnection = New SqlConnection(connString)
        'conn.Open()

        'Dim command As SqlCommand = New SqlCommand("UserDetails_Insert", conn)
        'command.CommandType = Data.CommandType.StoredProcedure

        'Dim dID As System.Data.SqlClient.SqlParameter = command.Parameters.Add("@Details_Id", System.Data.SqlDbType.Int)
        'dID.Direction = System.Data.ParameterDirection.ReturnValue

        'command.ExecuteScalar()
        'conn.Close()

        'Dim RecordId As String = command.Parameters("@Details_Id").Value.ToString()

        Response.Redirect("Profile.aspx")
    End Sub

    Protected Sub CompleteWizardStep1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles CompleteWizardStep1.PreRender
        Dim btnAppraiserProfile As Button = CType(CompleteWizardStep1.ContentTemplateContainer .FindControl("btnAppraiserProfile"), Button)
        If Session("UserType") = "2" Then
            btnAppraiserProfile.Visible = True
        Else
            btnAppraiserProfile.Visible = False
        End If
    End Sub

    Protected Sub SQLDSInsert_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEven tArgs)

        Response.Redirect("Registration.aspx")
    End Sub


End Class
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CreateUserWizard AghaKhan ASP.NET 2.0 Professional 1 December 5th, 2007 08:14 PM
Table definition for CreateUserWizard kutel ASP.NET 2.0 Basics 3 July 25th, 2007 09:57 AM
Secondary Data Source for Word Template Loralee Access 2 May 9th, 2006 07:48 PM
Scope_Identity with @Return_Value melbsurfer ASP.NET 2.0 Basics 1 April 28th, 2006 08:46 AM
How To Populate ListBox from a Secondary Data Sour luca ASP.NET 1.0 and 1.1 Basics 4 December 1st, 2004 05:24 PM



All times are GMT -4. The time now is 08:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.