public static Pos_AvAr Get(Int32 Identifiant) { Pos_AvAr pos_AvAr = new Pos_AvAr(); //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = select+" WHERE Identifiant = @Identifiant;"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres commande.Parameters.AddWithValue("Identifiant", Identifiant); //Execution try { connection.Open(); SqlDataReader dataReader = commande.ExecuteReader(); while (dataReader.Read()) { pos_AvAr.Identifiant = dataReader.GetInt32(0); pos_AvAr.Position = dataReader.GetString(1); } dataReader.Close(); } catch (Exception) { pos_AvAr = null; } finally { connection.Close(); } return pos_AvAr; }
public static Boolean Insert(Pos_AvAr pos_AvAr) { //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = @"INSERT INTO Pos_AvAr ("+champs+") VALUES (@Position);"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres commande.Parameters.AddWithValue("Position", pos_AvAr.Position); //Execution try { connection.Open(); commande.ExecuteNonQuery(); return true; } catch (Exception) { return false; } finally { connection.Close(); } }
public static Boolean Update(Pos_AvAr pos_AvAr) { //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = @"UPDATE Pos_AvAr SET Position=@Position WHERE Identifiant=@Identifiant ;"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres commande.Parameters.AddWithValue("Identifiant",pos_AvAr.Identifiant); commande.Parameters.AddWithValue("Position",pos_AvAr.Position ); //Execution try { connection.Open(); commande.ExecuteNonQuery(); return true; } catch (Exception) { return false; } finally { connection.Close(); } }
public static List<Pos_AvAr> List() { List<Pos_AvAr> listePos_AvAr = new List<Pos_AvAr>(); //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = select+";"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres //Execution try { connection.Open(); SqlDataReader dataReader = commande.ExecuteReader(); while (dataReader.Read()) { Pos_AvAr pos_AvAr = new Pos_AvAr(); pos_AvAr.Identifiant = dataReader.GetInt32(0); pos_AvAr.Position = dataReader.GetString(1); listePos_AvAr.Add(pos_AvAr); } dataReader.Close(); } catch (Exception) { listePos_AvAr = null; } finally { connection.Close(); } return listePos_AvAr; }