Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Metodo que devuelve resultados en un DataSet
- public SqlDataReader ejecutarSP_Retorna(String psp, List<Parametro> pparametros)
- {
- SqlCommand cmd;
- String nombre;
- //Se crea el comando
- cmd = new SqlCommand();
- SqlConnection conexion= getConection();
- //transformar la colección de parámetros en SqlParameter...
- foreach (Parametro objParametro in pparametros)
- {
- nombre = "@" + objParametro.Nombre;
- cmd.Parameters.AddWithValue(nombre, objParametro.Dato);
- }
- try
- {
- //se indica que se va a ejecutar un store procedure...
- cmd.CommandType = CommandType.StoredProcedure;
- //Se asigna el sp a ejecutar
- cmd.CommandText = psp;
- cmd.Connection.Open();
- cmd.ExecuteNonQuery();
- }
- catch (Exception e)
- {
- throw new Exception (e.Message);
- }
- return cmd.ExecuteReader();
- cmd.Connection.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment