1 Replies - 1152 Views - Last Post: 02 December 2013 - 07:23 AM Rate Topic: -----

#1 djasy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 02-February 12

no error with the stored procedure, but database doesn't update(Ac

Posted 02 December 2013 - 05:08 AM

i'm trying to update some informations in my database through a stored procedure called in asp.net(C#), i'm using an Access dataBase. it's a shoppingCart. i want to update the quantity of an item once it's already in the shoppingCart. i even use a message to be displayed if something goes wrong or not. it displayed that it succeded but the change doesn't happen. i got the same problem also when i try to add an existing item in the shopping cart. the update doesn't execute and i got no error! but it seems clear to me !
//méthode pour mettre à jour les données dans la table
    public static bool MajProduit(string produit, int qte)
    {
        //on obtient l'objet configuré DbCommande
        DbCommand m_cmd = LibAccesGenerique.CreerCmd();
        //on établit la procédure stockée
        if (qte <= 0)
            m_cmd.CommandText = "ShoppingCartDeleteProduits";
        else
            m_cmd.CommandText = "ShoppingCartUpdateProduit";
        //on créer les paramètres
        DbParameter m_param = m_cmd.CreateParameter();
        m_param.ParameterName = "@CartID";
        m_param.Value = ShoppingCartId;
        m_param.DbType = DbType.String;
        m_param.Size = 36;
        m_cmd.Parameters.Add(m_param);
        //on en crée un autre produit
        m_param = m_cmd.CreateParameter();
        m_param.ParameterName = "@Produit";
        m_param.Value = produit;
        m_param.DbType = DbType.Int32;
        m_cmd.Parameters.Add(m_param);
        //parametre qté
        m_param = m_cmd.CreateParameter();
        m_param.ParameterName = "@Quantite";
        m_param.Value = qte;
        m_param.DbType = DbType.Int32;
        m_cmd.Parameters.Add(m_param);
        //on retourne vrai si l'opération réussie
        try
        {
            //on execute la procédure stockée et retourne vrai, si la méthode s'est bien exécutée
            return (LibAccesGenerique.ExecuteNonQuery(m_cmd) != -1);
        }
        catch
        {
            return false;
        }
    }


this is my method for updating item. it's only working with the delete procedure.

Is This A Good Question/Topic? 0
  • +

Replies To: no error with the stored procedure, but database doesn't update(Ac

#2 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 271
  • View blog
  • Posts: 1,360
  • Joined: 03-December 12

Re: no error with the stored procedure, but database doesn't update(Ac

Posted 02 December 2013 - 07:23 AM

Have you verified that qte is passing a value higher that 0?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1