none
passing store procedure for inventry managemnt and maintaining stock table RRS feed

  • Question

  • hii.

    this is my question that i am using sqlbulk and columnmapping for saving data from excel sheet to database..but i need to use a store procedure when i insert datata from excel sheet to Product table then if same product is inserte 2 times then in stock tha total ammount will be increased and number of quantity will be also increased

    so i want to use store procedur for that so plz any one tell me that how i can use that procedure with example....

    Saturday, September 15, 2012 9:42 AM

Answers

  • Hi anuj,

    Welcome to the MSDN Forum.

    This issue is a language related issue, please ask it in language forum please. Or you can tell me which language you use, I will help to move it to corresponding forum.

    Anyway, here is an example about how to use Store Procedure in VB.net:

        Public Sub queryProc(Sql As String)
            Try
                'for sql server
                Dim conn As SqlConnection = New SqlConnection()
                conn.ConnectionString = ConnectionString
    
                'for SQL 
                Dim command1 As SqlCommand = New SqlCommand(Sql, conn)
                command1.CommandType = CommandType.StoredProcedure
    
                Dim p1 As SqlParameter = New SqlParameter("@Param1", "abc'efd")
                Dim p2 As SqlParameter = New SqlParameter("@Param2", "efghij\@#$%^&")
                Dim p3 As SqlParameter = New SqlParameter()
                p3.ParameterName = "@Param3"
                p3.SqlDbType = SqlDbType.VarChar
                p3.Direction = ParameterDirection.Output
                p3.Size = 60
                Dim p4 As SqlParameter = New SqlParameter()
                p4.ParameterName = "@Param4"
                p4.SqlDbType = SqlDbType.VarChar
                p4.Direction = ParameterDirection.Output
                p4.Size = 60
    
                command1.Parameters.AddRange({p1, p2, p3, p4})
                command1.Connection.Open()
                Dim r As SqlDataReader = command1.ExecuteReader()
                r.Close()
                Dim r2 As SqlDataReader = command1.ExecuteReader()
                'command1.Connection.Close()
                r2.Close()
                Console.WriteLine(p3.SqlValue)
                Console.WriteLine(p4.SqlValue)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 17, 2012 10:42 AM
    Moderator