Results 1 to 2 of 2

Thread: Advice using sql_sp to insert data

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    6

    Advice using sql_sp to insert data

    Hello All GoodMorning,

    I created a sql stored procedure that will insert data for me depending on user input. Now I would like to know usually I would do something of this nature
    Code:
     Dim con As New SqlConnection(connectionString)
            Dim cmd As New SqlCommand("usp_userinput", con) 'references connectionstring and calls store procedure
            cmd.CommandType = Data.CommandType.StoredProcedure 'sets default to be storeprocedure
            lblMessage.Text = String.Empty
    
            With cmd.Parameters
                If (Session("UserInitials")) IsNot Nothing Then
                    .AddWithValue("@UserInitials", Session("UserInitials").ToString())
                End If
    End With
    That is just an example how i usually approach calling the stored procedure in vb. However for this particular form I am going to have 50 or 60 textboxes which each one would require a session state variable.Seems a little tedious to have to create a session state variable for each textbox on the form

    was hoping there was a more efficient way to approach this if so is there anything i can reference in order to understand how to do this.

    Thanks in advance for any help

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Advice using sql_sp to insert data

    Rather than storing User Initials in session state, you could pass them to you function directly.
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width