C# Programming
05-11-2009, 08:12 PM
Hi everybody!
Hi have a problem when read dates from a strored procedure:
CREATE PROCEDURE
Articulos_GetByCodigo
(
@ParametroEntrada nvarchar(7)
)
AS
SET NOCOUNT ON
SELECT Gestion
FROM msTablaGestion
WHERE msTablaGestion.Codigo = @ParametroEntrada
SET QUOTED_IDENTIFIER OFF
GO
I call the method from a external method in the same class like this:
ExecuteStoreProcedure("Articulos_GetByCodigo", numeroPL);
articuloPermitido = reader.GetBoolean(0);
this is my method:
public void ExecuteStoreProcedure(string nombreProcedimiento,string parametro)
{
using (SqlConnection connection = new SqlConnection(cadenaConexion))
{
using (SqlCommand command = new SqlCommand(nombreProcedimiento,connection))
{
connection.Open();
//command.Connection = connection;
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = nombreProcedimiento;
command.CommandTimeout = 10;
command.Parameters.AddWithValue("@parametroEntrada", parametro);
reader = command.ExecuteReader();
}
}
}
I receive in the call this : Metadata attempt invalid when the reader is closed
I think should be because i call the method and later the reader is closed, any have some sugestion.
P.D. I write the method outside because i want use this in another calls with another paremetres.
Thanks in advance
Hi have a problem when read dates from a strored procedure:
CREATE PROCEDURE
Articulos_GetByCodigo
(
@ParametroEntrada nvarchar(7)
)
AS
SET NOCOUNT ON
SELECT Gestion
FROM msTablaGestion
WHERE msTablaGestion.Codigo = @ParametroEntrada
SET QUOTED_IDENTIFIER OFF
GO
I call the method from a external method in the same class like this:
ExecuteStoreProcedure("Articulos_GetByCodigo", numeroPL);
articuloPermitido = reader.GetBoolean(0);
this is my method:
public void ExecuteStoreProcedure(string nombreProcedimiento,string parametro)
{
using (SqlConnection connection = new SqlConnection(cadenaConexion))
{
using (SqlCommand command = new SqlCommand(nombreProcedimiento,connection))
{
connection.Open();
//command.Connection = connection;
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = nombreProcedimiento;
command.CommandTimeout = 10;
command.Parameters.AddWithValue("@parametroEntrada", parametro);
reader = command.ExecuteReader();
}
}
}
I receive in the call this : Metadata attempt invalid when the reader is closed
I think should be because i call the method and later the reader is closed, any have some sugestion.
P.D. I write the method outside because i want use this in another calls with another paremetres.
Thanks in advance