1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#region declaration
Connexion cn;
SqlCommand cm;
SqlTransaction trans = null;
SqlDataAdapter da;
#endregion
try
{
this.m_strDescriptionErreur = "";
// Ouverture de la connexion
cn = new Connexion();
if (cn.OuvrirConnexion())
{
#region execution de la procédure stockée procGestionApplication_ListeNiveaux
// Création de la transaction
trans = cn.ConnexionActive.BeginTransaction();
// Création de la commande de mise à jour
cm = new SqlCommand();
cm.CommandType = CommandType.StoredProcedure;
cm.Transaction = trans;
cm.Connection = cn.ConnexionActive;
cm.CommandText = "procGestionApplication_ListeNiveaux";
// Liste des paramètres
// @ID_Niveau int Identifiant
// @ProfondeurLimite int Profondeur
cm.Parameters.Add(new SqlParameter("@ID_Niveau", SqlDbType.Int, 4));
cm.Parameters.Add(new SqlParameter("@ProfondeurLimite", SqlDbType.Int, 4));
// Initialisation des paramètres en entrée
cm.Parameters["@ID_Niveau"].Value = m_intIdNiveau;
cm.Parameters["@ProfondeurLimite"].Value = m_intProfondeur + p_intProfondeur;
// Execution de la requete bug
p_dtb_ListeNiveaux = new DataTable();
da = new SqlDataAdapter(cm);
da.Fill(p_dtb_ListeNiveaux);
//SqlDataReader toto;
//toto = cm.ExecuteReader();
//toto.Close();
// Validation de la transaction
trans.Commit();
// Fermeture de la connexion
cn.FermerConnexion();
return true;
#endregion
}
#region erreur connexion
else
{
// Récupération e l'erreur d'ouverture de la connexion
this.m_strDescriptionErreur = cn.DescriptionErreur;
return false;
}
#endregion
}
#region catch
catch (Exception ex)
{
// Annulation de la transaction si elle est ouverte
if (trans != null) trans.Rollback();
// Récupération de l'erreur d'ouverture de la connexion
this.m_strDescriptionErreur = ex.Message;
return false;
}
#endregion
#region finally
finally
{
cm = null;
trans = null;
cn = null;
}
#endregion
} |
Partager