|
-
Dec 3rd, 2003, 05:24 PM
#1
Thread Starter
New Member
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
-
Dec 3rd, 2003, 05:59 PM
#2
Frenzied Member
have you tried doing
VB Code:
cmd.Parameters.Add(@product, 3)
cmd.Parameters.Add(@qty, 3)
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Dec 3rd, 2003, 06:02 PM
#3
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:
cmd.Parameters.Add(New OdbcParameter("@product", 3) )
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|