Results 1 to 3 of 3

Thread: call store procedures

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Posts
    11

    call store procedures

    I make this store procedure:

    CREATE PROCEDURE sp_SubstractInventory

    (
    @product int,
    @qty int


    AS
    Update tblInventario set stock = (stock-@qty) where num = @product
    /* SET NOCOUNT ON */
    RETURN
    GO

    I try to run this code with this code in VB .Net:

    Dim dr As OdbcDataReader
    Dim cmd As OdbcCommand = New OdbcCommand("sp_SubstractInventory", cn)
    cmd.CommandType = CommandType.StoredProcedure
    Dim param1 As OdbcParameter = New OdbcParameter("@product", 3)
    Dim param2 As OdbcParameter = New OdbcParameter("@qty", 3)
    param1.Direction = ParameterDirection.Input
    param2.Direction = ParameterDirection.Input
    cn.Open()
    dr = cmd.ExecuteReader()
    cn.Close()

    The debuger sends me this error:

    ERROR [4200] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'sp_SubstractInventory' expects parameter '@product' wich was not supplied.

    Please let me know what is the problem I got

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    have you tried doing
    VB Code:
    1. cmd.Parameters.Add(@product, 3)
    2. cmd.Parameters.Add(@qty, 3)
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Why are you using ODBC instead of SQL? I didn't see the creation of your connection object in there so I don't know if you were really meaning to use a DSN or what. Also if the Parameter direction is in then it is set that way by default and there is no need to set it to that. Anyway on to the problem: You never attached the parameters to the command. Make the following changes:
    VB Code:
    1. cmd.Parameters.Add(New OdbcParameter("@product", 3) )
    2. cmd.Parameters.Add(New OdbcParameter("@qty", 3) )

    'I must be typing slow today

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