G
Guest
Hi All,
I am trying to pass parameters to a stored procedure from vb.net code and
fails with the error that the variable is not a parameter to the stored
procedure
Here is the vb.net cod
----------------------------------------------------------------------------------------------
command = New SqlCommand("sp_updateProducts")
command.Connection = connection
command.CommandType = CommandType.StoredProcedure
command.Transaction = trans
command.Parameters.Add(New SqlParameter("@pMacId",
SqlDbType.Char))
command.Parameters.Add(New SqlParameter("@pProdDt",
SqlDbType.DateTime))
command.Parameters.Add(New SqlParameter("@pProdInfo",
SqlDbType.VarChar))
command.Parameters(0).Direction = ParameterDirection.Input
command.Parameters(1).Direction = ParameterDirection.Input
command.Parameters(2).Direction = ParameterDirection.Input
command.Parameters(0).Value = machineID
command.Parameters(1).Value = updateDate
command.Parameters(2).Value = joinStr
command.ExecuteNonQuery()
-----------------------------------------------------------------------------------------------
Here is the stored procedure code:
-----------------------------------------------------------------------------------------------
CREATE PROCEDURE dbo.sp_updateProducts
(
@pMachineId AS CHAR(6),
@pProdDt AS DATETIME,
@pProdinfo VARCHAR(4000)
)
AS
BEGIN
.......
.......
.......
END
G
-----------------------------------------------------------------------------------------------
The error message occurs on ExecuteNonQuery() and says that @pMacId is not a
prameter to the stored procedure sp_updateProducts
I may be missing something very naive! Could anybody suggest the cause of
the error?
Thanks
kd
I am trying to pass parameters to a stored procedure from vb.net code and
fails with the error that the variable is not a parameter to the stored
procedure
Here is the vb.net cod
----------------------------------------------------------------------------------------------
command = New SqlCommand("sp_updateProducts")
command.Connection = connection
command.CommandType = CommandType.StoredProcedure
command.Transaction = trans
command.Parameters.Add(New SqlParameter("@pMacId",
SqlDbType.Char))
command.Parameters.Add(New SqlParameter("@pProdDt",
SqlDbType.DateTime))
command.Parameters.Add(New SqlParameter("@pProdInfo",
SqlDbType.VarChar))
command.Parameters(0).Direction = ParameterDirection.Input
command.Parameters(1).Direction = ParameterDirection.Input
command.Parameters(2).Direction = ParameterDirection.Input
command.Parameters(0).Value = machineID
command.Parameters(1).Value = updateDate
command.Parameters(2).Value = joinStr
command.ExecuteNonQuery()
-----------------------------------------------------------------------------------------------
Here is the stored procedure code:
-----------------------------------------------------------------------------------------------
CREATE PROCEDURE dbo.sp_updateProducts
(
@pMachineId AS CHAR(6),
@pProdDt AS DATETIME,
@pProdinfo VARCHAR(4000)
)
AS
BEGIN
.......
.......
.......
END
G
-----------------------------------------------------------------------------------------------
The error message occurs on ExecuteNonQuery() and says that @pMacId is not a
prameter to the stored procedure sp_updateProducts
I may be missing something very naive! Could anybody suggest the cause of
the error?
Thanks
kd