Click here to Skip to main content
14,542,702 members
   

C#

 
GeneralRe: problem to retrieve an info in a sql request / problème pour recéper une info dans une requête sql Pin
ago248616-Mar-20 7:08
Memberago248616-Mar-20 7:08 
GeneralRe: problem to retrieve an info in a sql request / problème pour recéper une info dans une requête sql Pin
OriginalGriff16-Mar-20 7:10
mveOriginalGriff16-Mar-20 7:10 
GeneralRe: problem to retrieve an info in a sql request / problème pour recéper une info dans une requête sql Pin
ago248616-Mar-20 7:10
Memberago248616-Mar-20 7:10 
Generalrecording problem Pin
ago248617-Mar-20 0:47
Memberago248617-Mar-20 0:47 
GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 1:24
mveOriginalGriff17-Mar-20 1:24 
GeneralRe: recording problem Pin
ago248617-Mar-20 2:07
Memberago248617-Mar-20 2:07 
GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 2:13
mveOriginalGriff17-Mar-20 2:13 
GeneralRe: recording problem Pin
ago248617-Mar-20 2:21
Memberago248617-Mar-20 2:21 
Ok, thank you sir. I removed my block of code in the try and here is the error: at the level of sql_cmd.ExecuteNonQuery ();
System.Data.OleDb.OleDbException: 'No value given for one or more of the required parameters.'


private void BtnAjouter_Click(object sender, EventArgs e)
        {
            int total;
            decimal total_achat;
            //si les champs sont vides
            if (TxtDesignation.Text == "" || TxtPrixUnitaire.Text == "" || TxtQteCmd.Text == "" || TxtQteStock.Text == "" || TxtRefProduit.Text == "")
            {
                MessageBox.Show("Rassurez vous que tous les champs ont bien été rempli.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //Vérifier si la valeur saisie est numeric
                if (Int32.TryParse(TxtQteCmd.Text, out int value) && TxtRefProduit.Text != "")
                {
                    //Vérifier si la commande est inferieur ou egale au stock
                    int a = 0;
                    int b = 0;
                    int c;

                    //Convertire les textBox en int
                    int.TryParse(TxtQteCmd.Text.Trim(), out a);
                    int.TryParse(TxtQteStock.Text.Trim(), out b);
                    int.TryParse(TxtPrixUnitaire.Text.Trim(), out c);

                    if (a <= b)
                    {
                        total = a * c;
                        total_achat = 0;

                        //try
                       // {
                            setConnection();
                            sql_con.Open();
                           using (sql_cmd = sql_con.CreateCommand())
                            {
                               string txtQuery = "INSERT INTO Detail_temp (ref_det, qute_det, Designation, Prix_unitaire_HT, Prix_total_HT) VALUES (@ref_det,@qute_det,@Designation,@Prix_unitaire_HT,@Prix_total_HT)";
                               sql_cmd.Parameters.AddWithValue("@ref_det", TxtRefProduit.Text);
                               sql_cmd.Parameters.AddWithValue("@qute_det", TxtQteCmd.Text);
                               sql_cmd.Parameters.AddWithValue("@Designation", TxtDesignation.Text);
                               sql_cmd.Parameters.AddWithValue("@Prix_unitaire_HT", TxtPrixUnitaire.Text);
                               sql_cmd.Parameters.AddWithValue("@Prix_total_HT", total);
                               sql_cmd = new OleDbCommand(txtQuery, sql_con);
                               sql_cmd.ExecuteNonQuery();
                                //ExecuteQuery(txtQuery);
                            }
                       // }
                       // catch(OleDbException ex)
                       // {
                            //MessageBox.Show(ex.Source);
                        //}

GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 2:34
mveOriginalGriff17-Mar-20 2:34 
GeneralRe: recording problem Pin
ago248617-Mar-20 2:40
Memberago248617-Mar-20 2:40 
GeneralRe: recording problem Pin
ago248617-Mar-20 2:43
Memberago248617-Mar-20 2:43 
GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 2:51
mveOriginalGriff17-Mar-20 2:51 
GeneralRe: recording problem Pin
ago248617-Mar-20 3:02
Memberago248617-Mar-20 3:02 
GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 3:17
mveOriginalGriff17-Mar-20 3:17 
GeneralRe: recording problem Pin
ago248617-Mar-20 3:24
Memberago248617-Mar-20 3:24 
GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 3:38
mveOriginalGriff17-Mar-20 3:38 
GeneralRe: recording problem Pin
ago248617-Mar-20 3:52
Memberago248617-Mar-20 3:52 
GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 4:08
mveOriginalGriff17-Mar-20 4:08 
GeneralRe: recording problem Pin
ago248617-Mar-20 4:28
Memberago248617-Mar-20 4:28 
GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 4:31
mveOriginalGriff17-Mar-20 4:31 
GeneralRe: recording problem Pin
ago248617-Mar-20 4:39
Memberago248617-Mar-20 4:39 
AnswerRe: recording problem Pin
ZurdoDev17-Mar-20 2:39
mveZurdoDev17-Mar-20 2:39 
GeneralRe: recording problem Pin
OriginalGriff17-Mar-20 2:52
mveOriginalGriff17-Mar-20 2:52 
GeneralRe: recording problem Pin
ZurdoDev17-Mar-20 2:59
mveZurdoDev17-Mar-20 2:59 
GeneralRe: recording problem Pin
Luc Pattyn17-Mar-20 12:08
sitebuilderLuc Pattyn17-Mar-20 12:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.