Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public void OpenConnexion()
        {
            try
            {
                 conn = new SqlConnection(@"Data Source=RAJ;Initial Catalog=GENIUS;Integrated Security=True");
                
                
                conn.Open();
            }
            catch (Exception e)
            {
                MessageBox.Show("Erreur de Connexion de la base");

            }


        }

public void InsertLP(LignePiece LP)
        {
            OpenConnexion();

            cmd = new SqlCommand("INSERT INTO F_LIGNEPIECE (EP_No,EP_Date,EP_Reference,EP_Tiers,CT_Intitule,AR_Ref,AR_Design,LP_QteMvt,LP_ValeurRemise,LP_TypeRemise,LP_TTC,LP_MontantHT,LP_MontantTTC,LP_PrixUnitaire,LP_PUTTC,LP_CodeTaxeTVA,LP_TauxTVA,N_CatCompta) VALUES" +
                                 " (,@EP_No,@EP_Date,@EP_Reference,@EP_Tiers,@CT_Intitule,@AR_Ref,@AR_Design,@LP_QteMvt,@LP_ValeurRemise,@LP_TypeRemise,@LP_TTC,@LP_MontantHT,@LP_MontantTTC,@LP_PrixUnitaire,@LP_PUTTC,@LP_CodeTaxeTVA,@LP_TauxTVA,@N_CatCompta,)", conn);
              cmd.Parameters.Add("@EP_No", LP.EP_No);
          
            cmd.Parameters.Add("@EP_Date", LP.EP_Date);
            cmd.Parameters.Add("@EP_Reference", LP.EP_Reference);
            cmd.Parameters.Add("@EP_Tiers", LP.EP_Tiers);
            cmd.Parameters.Add("@CT_Intitule", LP.CT_Intitule);
            cmd.Parameters.Add("@AR_Ref", LP.AR_Ref);
            cmd.Parameters.Add("@AR_Design", LP.AR_Design);
            cmd.Parameters.Add("@LP_QteMvt", LP.LP_QteMvt);
            cmd.Parameters.Add("@LP_ValeurRemise", LP.LP_ValeurRemise);
            cmd.Parameters.Add("@LP_TypeRemise", LP.LP_TypeRemise);
            cmd.Parameters.Add("@LP_TTC", LP.LP_TTC);
            cmd.Parameters.Add("@LP_MontantHT", LP.LP_MontantHT);
            cmd.Parameters.Add("@LP_MontantTTC", LP.LP_MontantTTC);
            cmd.Parameters.Add("@LP_PrixUnitaire", LP.LP_PrixUnitaire);
            cmd.Parameters.Add("@LP_PUTTC", LP.LP_PUTTC);
            cmd.Parameters.Add("@LP_CodeTaxeTVA", LP.LP_CodeTaxeTVA);
            cmd.Parameters.Add("@LP_TauxTVA", LP.LP_TauxTVA);
            cmd.Parameters.Add("@N_CatCompta",LP.N_CatCompta);
            cmd.ExecuteNonQuery();
            conn.Close();
        }


What I have tried:

I have another views and Inserts into the same Database "GENIUS "it all works but this one is not . It did not show any error but i can't find the results into SQL-Server Table
Posted
Updated 2-Jun-18 18:54pm
v2

1 solution

I'm betting it does show an error: your list of values starts with a comma which should be a syntax error:
... VALUES" +
" (,@EP_No, ...
Use the debugger to single step the ExecuteNonQuery line, and I think you'll find you get an exception.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900