コード例 #1
0
        //Recherche dans la base de données
        public DataTable rechercher(Couverture uneCouverture)
        {
            _connexion.OuvrirConnexion();
            commande             = new MySqlCommand();
            commande.CommandText = "proc_rechercher_couverture"; //Nom de la rpocédure sur MySql
            commande.CommandType = CommandType.StoredProcedure;  //Indique que c'est une procedure
            commande.Connection  = _connexion.getConnexion();
            commande.Parameters.Add(new MySqlParameter("unCode", MySqlDbType.Int16));
            commande.Parameters["unCode"].Value = uneCouverture.getCodeBd();
            commande.Parameters.Add(new MySqlParameter("unTitre", MySqlDbType.String));
            commande.Parameters["unTitre"].Value = uneCouverture.getTitreBd();
            commande.Parameters.Add(new MySqlParameter("unTome", MySqlDbType.Int16));
            commande.Parameters["unTome"].Value = uneCouverture.getTomeBd();
            commande.Parameters.Add(new MySqlParameter("uneDate", MySqlDbType.String));
            commande.Parameters["uneDate"].Value = uneCouverture.getAnneeParution();

            MySqlDataAdapter unAdapter = new MySqlDataAdapter(commande);
            DataSet          unDataset = new DataSet();
            DataTable        uneRecherche;

            uneRecherche = new DataTable();
            unAdapter.Fill(unDataset, "couverture");
            uneRecherche = unDataset.Tables["couverture"];

            _connexion.closeConnexion();

            return(uneRecherche);
        }
コード例 #2
0
        //On vérifie si le N°Tome existe
        public bool getTomeExist(Couverture uneCouverture)
        {
            _connexion.OuvrirConnexion();
            commande             = new MySqlCommand();
            commande.CommandText = "proc_tomeExist_couverture"; //Nom de la rpocédure sur MySql
            commande.CommandType = CommandType.StoredProcedure; //Indique que c'est une procedure
            commande.Connection  = _connexion.getConnexion();
            commande.Parameters.Add(new MySqlParameter("unTome", MySqlDbType.Int16));
            commande.Parameters["unTome"].Value = uneCouverture.getTomeBd();
            MySqlParameter PSortie_nat = new MySqlParameter("ret", MySqlDbType.String);

            commande.Parameters.Add(PSortie_nat);
            PSortie_nat.Direction = ParameterDirection.Output;
            IDataReader reader = commande.ExecuteReader();

            reader.Read();

            int unCode = reader.GetInt16(0);

            if (unCode == 1)
            {
                retour = true;
            }
            else
            {
                retour = false;
            }
            reader.Close();
            _connexion.closeConnexion();
            return(retour);
        }