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
| public ArrayList affichage_article(int catid)
{
MySqlDataReader dr = null;
ArrayList liste = null;
Article a = null;
using (MySqlConnection conn = new MySqlConnection(global.connection))
{
MySqlCommand cmd = new MySqlCommand();
conn.Open();
try
{
cmd.Connection = conn;
cmd.CommandText = "Select article.id_article,id_categorie,introduction,titre,corps,date_redac,etat_article from article inner join statut on article.id_article=statut.id_article where id_categorie=" + catid + "";
Dr = cmd.ExecuteReader();
liste = new ArrayList();
//liste.Add("84984984");
while (dr.Read())
{
a = new article();
a.id_article = int.Parse(Dr["id_article"].ToString());
a.id_categorie = int.Parse(Dr["id_categorie"].ToString());
a.id_user = int.Parse(Dr["id_user"].ToString());
a.introduction = Dr["introduction"].ToString();
a.date_redac = DateTime.Parse(Dr["date_redac"].ToString());
a.titre = Dr["titre"].ToString();
a.statut = Dr["etat_statut"].ToString();
liste.Add(a);
}
dr.Close();
}
catch(Exception ex)
{
if (dr != null)
if (!dr.IsClosed) dr.Close();
throw ex;
}
return liste;
}
} |