public ENTResponse SelectEstado(ENTEstado oENTEstado, String sConnection, Int32 iAlternateDBTimeout)
{
SqlConnection sqlCnn = new SqlConnection(sConnection);
SqlCommand sqlCom;
SqlParameter sqlPar;
SqlDataAdapter sqlDA;
ENTResponse oENTResponse = new ENTResponse();
// Configuración de objetos
sqlCom = new SqlCommand("uspcatEstado_Sel", sqlCnn);
sqlCom.CommandType = CommandType.StoredProcedure;
// Timeout alternativo en caso de ser solicitado
if (iAlternateDBTimeout > 0) { sqlCom.CommandTimeout = iAlternateDBTimeout; }
// Parametros
sqlPar = new SqlParameter("EstadoId", SqlDbType.Int);
sqlPar.Value = oENTEstado.EstadoId;
sqlCom.Parameters.Add(sqlPar);
sqlPar = new SqlParameter("PaisId", SqlDbType.Int);
sqlPar.Value = oENTEstado.PaisId;
sqlCom.Parameters.Add(sqlPar);
sqlPar = new SqlParameter("Nombre", SqlDbType.VarChar);
sqlPar.Value = oENTEstado.Nombre;
sqlCom.Parameters.Add(sqlPar);
sqlPar = new SqlParameter("Activo", SqlDbType.TinyInt);
sqlPar.Value = oENTEstado.Activo;
sqlCom.Parameters.Add(sqlPar);
// Inicializaciones
oENTResponse.dsResponse = new DataSet();
sqlDA = new SqlDataAdapter(sqlCom);
// Transacción
try
{
sqlCnn.Open();
sqlDA.Fill(oENTResponse.dsResponse);
sqlCnn.Close();
}catch (SqlException sqlEx){
oENTResponse.ExceptionRaised(sqlEx.Message);
}catch (Exception ex){
oENTResponse.ExceptionRaised(ex.Message);
}finally{
if (sqlCnn.State == ConnectionState.Open) { sqlCnn.Close(); }
sqlCnn.Dispose();
}
// Resultado
return oENTResponse;
}