Hola a todos:
Tengo el siguiente problema. Quiero ejecutar un Stored Procedure y me da un error. Estoy trabado ahí y no puedo saber porque.
Copio tanto el código, como es procedimiento.
Gracias
-----------------------------------------------------------------------------------------------
//Código
--Valores heredados-------------------------------------------------------------------------
miParametro(0) = "@ART_COD"
miParametro(1) = "22"
miParametro(2) = "10"
miParametro(3) = "1001b"
miProcedimiento = "prc_art_dep"
------------------------------------------------------------------------------------------------
Dim sqlAdapter As New SqlDataAdapter
Dim miCommand As New SqlCommand
Dim sqlParameter As New SqlParameter(miParametro(0), CInt(miParametro(1)), CInt(miParametro(2)))
sqlParameter.Value = miParametro(3)
miCommand.CommandType = CommandType.StoredProcedure
miCommand.CommandText = miProcedimiento
miCommand.Parameters.Add(sqlParameter)
sqlAdapter.SelectCommand = miCommand
sqlAdapter.SelectCommand.Connection = dbConnection 'dbConnecton ya esta conectado
sqlAdapter.Fill(dbDataSet, miProcedimiento) ' dbDataSet ya esta iniciado
-------------------------------------------------------------------------------------------
ERROR:
"Procedure or function 'prc_art_dep' expects parameter '@ART_COD', which was not supplied."
-------------------------------------------------------------------------------------------
// - Procedimiento
-------------------------------------------------------------------------------------------
USE [SiADdb1]
GO
/****** Object: StoredProcedure [dbo].[prc_art_dep] Script Date: 06/03/2013 23:46:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[prc_art_dep] (
@ART_COD varchar(10) )
AS
BEGIN
SET NOCOUNT ON;
SELECT art_stk.art_cod as art_cod,
dep.dep_id as dep_id,
dep.dep_desc as dep_des,
art_stk.art_stk_min as stk_min,
art_stk.art_stk_max as stk_max
FROM
(Select * from art_stk Where art_cod = @ART_COD) as art_stk
RIGHT OUTER JOIN
(Select * from dep where dep_stk = 1) as dep
ON art_stk.dep_id = dep.dep_id
order by dep.dep_id
END
------------------------------------------------------------------------------
//******* Este procedimiento ejecutado desde el mismo SQL Server anda perfecto
------------------------------------------------------------------------------
exec prc_art_dep '1001b'
1001b
1
DEPOSITO 1
20
100
NULL
2
DEPOSITO 2
NULL
NULL
NULL
3
DEPOSITO 3
NULL
NULL
NULL
4
DEPOSITO 4
NULL
NULL
NULL
5
DEPOSITO 5
NULL
NULL
NULL
98
OFERTAS
NULL
NULL