Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/02/2007, 13:18
gustavo_sierra
 
Fecha de Ingreso: febrero-2007
Mensajes: 1
Antigüedad: 17 años, 2 meses
Puntos: 0
SqlParameters problemas de recuperar valor de output de un procedure

Que tal foro,

me gustaria me ayudaran con un problema que tengo.

el código a continuacion es el que me presenta dificultades, ya que necesito que a la variable de tipo int codigo_materia se le asigne el valor devuelto por el procedure en su variable @CODIGO_MATERIA...

el procedure funciona y si retorna el valor correspondiente, solo que no logro recurperarlo desde la aplicacion. la linea en rojo es la que necesito funcione ya que la variable codigo_materia la uso en el bucle de mas abajo para otra insercion...

la mecanica es cabecera - detalle.

oComm = new SqlCommand();
oComm.CommandType = CommandType.StoredProcedure;
oComm.CommandText = "PM_INGRESO_MATERIA";
oComm.Connection = oConn;
oComm.Transaction = transaccion;
oComm.Parameters.AddWithValue("@MAESTRIA", codigo_maestria);
oComm.Parameters.AddWithValue("@NOMBRE_MATERIA", nombre_materia);
oComm.Parameters.AddWithValue("@MAESTRO_PRINCIPAL" , codigo_maestro_principal);
oComm.Parameters.AddWithValue("@MAESTRO_PRINCIPAL" , codigo_maestro_principal);
oComm.Parameters.AddWithValue("@CODIGO_MATERIA", codigo_materia).Direction = ParameterDirection.Output;


codigo_materia = (Int32)oComm.Parameters["@CODIGO_MATERIA"].Value;



for (int i = 0; i <= maximo;i++ )
{
oComm.CommandText = "PM_INGRESO_MATERIA_DETALLE";
oComm.Connection = oConn;
oComm.Parameters.AddWithValue("@MATERIA", codigo_materia);
oComm.Parameters.AddWithValue("@MAESTRO_PRINCIPAL" , codigo_maestro_principal);
oComm.Parameters.AddWithValue("@PARALELO", detalle_paralelo[i]);
oComm.Parameters.AddWithValue("@MAESTRO_SUPLENTE", detalle_profesor[i]);
}
oComm.ExecuteNonQuery();


------------------------------------------------
------------------------------------------------
muy agradecido les quedo amigos...

Gustavo Sierra