Tengo un método el cual me ayuda a ejecutar un sp y devuelve un reader:
public object EjecutarReaderStoredProcedure(string textoComando)
{
if (string.IsNullOrEmpty(textoComando.Trim()))
{
throw new ArgumentException("No se especificó el comando", "string textoComando");
}
IDataReader reader = null;
IDbCommand comando = null;
try
{
this.conexion.Open();
comando = PrepararComando(textoComando, CommandType.StoredProcedure, null);
comando.CommandTimeout = 0;
reader = comando.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (Exception ex)
{
throw ex;
}
finally
{
comando.Dispose();
comando = null;
}
return reader;
}
Cómo puedo leer los datos de ese método en una pagina de .net ya que lo hago de esta manera pero solo me devuelve System.Data.SqlClient.SqlDataReader
AdministraAccesoDatos ad = new AdministraAccesoDatos("xxx",SqlServer);
object dr= ad.EjecutarReaderStoredProcedure("SP_MostrarVariables");
ViewBag.MuestraVariables = dr;
object dr
? usavar dr
o mejor en este caso,DataReader
EjecutarReaderStoredProcedure
devuelveobject
no se muy bien porqué. Cambia el tipo devuelto de ese método.