Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. problem to retrieve an info in a sql request / problème pour recéper une info dans une requête sql

problem to retrieve an info in a sql request / problème pour recéper une info dans une requête sql

Scheduled Pinned Locked Moved C#
databasehelp
45 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A ago2486

    Hello sir and thank you for your help. I did as you advised me but I have a microsoft jet engine error. I will see another tutorial on this subject if I will find a solution ...

    Richard DeemingR Offline
    Richard DeemingR Offline
    Richard Deeming
    wrote on last edited by
    #9

    If you want someone to help you fix an error, you need to give us the full details of the error.


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

    A 2 Replies Last reply
    0
    • Richard DeemingR Richard Deeming

      If you want someone to help you fix an error, you need to give us the full details of the error.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      A Offline
      A Offline
      ago2486
      wrote on last edited by
      #10

      ok thank you sir. But there is not much detail except that when I submit the button to add I receive the message microsoft jet engine.

      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();
      
      Richard DeemingR 2 Replies Last reply
      0
      • Richard DeemingR Richard Deeming

        If you want someone to help you fix an error, you need to give us the full details of the error.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        A Offline
        A Offline
        ago2486
        wrote on last edited by
        #11

        and here is my connection

        private void setConnection()
        {
        try
        {
        string connetionString = null;
        //connection à la base de donnée avec mot de passe
        connetionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Application.StartupPath + @"\DB_CaisseEnregistreuse.mdb;Persist Security Info=True;Jet OLEDB:Database Password=B@sta08091987";
        sql_con = new OleDbConnection(connetionString);
        }
        catch (Exception ex)
        {
        MessageBox.Show("Erreur de connexion à la base donnée" + ex.Message);
        }

            }
        
        L 1 Reply Last reply
        0
        • A ago2486

          ok thank you sir. But there is not much detail except that when I submit the button to add I receive the message microsoft jet engine.

          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();
          
          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #12

          That's not the full error message.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          A 2 Replies Last reply
          0
          • Richard DeemingR Richard Deeming

            That's not the full error message.


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            A Offline
            A Offline
            ago2486
            wrote on last edited by
            #13

            I followed your advice, sir, regarding possible SQL injection. I may be wrong but I made the parameter request as you told me, but if he has other errors, can you help me please

            Richard DeemingR 1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              That's not the full error message.


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              A Offline
              A Offline
              ago2486
              wrote on last edited by
              #14

              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)
              
              1 Reply Last reply
              0
              • A ago2486

                hello sir all my apologies for the delay ... i was putting my code clean as you advised me. I have an error like microsoft jet engine

                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);
                }

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #15

                Quote:

                I have an error like microsoft jet engine

                Is pretty meaningless on it's own ...

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                A 1 Reply Last reply
                0
                • A ago2486

                  I followed your advice, sir, regarding possible SQL injection. I may be wrong but I made the parameter request as you told me, but if he has other errors, can you help me please

                  Richard DeemingR Offline
                  Richard DeemingR Offline
                  Richard Deeming
                  wrote on last edited by
                  #16

                  Sorry, I posted that before I noticed that you'd commented-out the vulnerable code.


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                  A 1 Reply Last reply
                  0
                  • Richard DeemingR Richard Deeming

                    Sorry, I posted that before I noticed that you'd commented-out the vulnerable code.


                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                    A Offline
                    A Offline
                    ago2486
                    wrote on last edited by
                    #17

                    thank you sir i was afraid i didn't do what you told me.

                    1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      Quote:

                      I have an error like microsoft jet engine

                      Is pretty meaningless on it's own ...

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                      A Offline
                      A Offline
                      ago2486
                      wrote on last edited by
                      #18

                      You are right sir but frankly I don't know how to explain it to you. but once I submit the add button after filling in all the fields as it should be this is the message I receive. And nothing in the access database.

                      OriginalGriffO 1 Reply Last reply
                      0
                      • A ago2486

                        You are right sir but frankly I don't know how to explain it to you. but once I submit the add button after filling in all the fields as it should be this is the message I receive. And nothing in the access database.

                        OriginalGriffO Offline
                        OriginalGriffO Offline
                        OriginalGriff
                        wrote on last edited by
                        #19

                        What is the message you recieve? What line does it happen on? What does the debugger show you is going on? So far, all I have is "I have an error like microsoft jet engine" which tells me nothing at all!

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                        A 1 Reply Last reply
                        0
                        • A ago2486

                          and here is my connection

                          private void setConnection()
                          {
                          try
                          {
                          string connetionString = null;
                          //connection à la base de donnée avec mot de passe
                          connetionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Application.StartupPath + @"\DB_CaisseEnregistreuse.mdb;Persist Security Info=True;Jet OLEDB:Database Password=B@sta08091987";
                          sql_con = new OleDbConnection(connetionString);
                          }
                          catch (Exception ex)
                          {
                          MessageBox.Show("Erreur de connexion à la base donnée" + ex.Message);
                          }

                              }
                          
                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #20

                          But what is the error message?

                          A 1 Reply Last reply
                          0
                          • OriginalGriffO OriginalGriff

                            What is the message you recieve? What line does it happen on? What does the debugger show you is going on? So far, all I have is "I have an error like microsoft jet engine" which tells me nothing at all!

                            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                            A Offline
                            A Offline
                            ago2486
                            wrote on last edited by
                            #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);
                            
                            OriginalGriffO Z 2 Replies Last reply
                            0
                            • L Lost User

                              But what is the error message?

                              A Offline
                              A Offline
                              ago2486
                              wrote on last edited by
                              #22

                              System.Data.OleDb.OleDbException: 'No value given for one or more of the required parameters.'

                              L 1 Reply Last reply
                              0
                              • A ago2486

                                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);
                                
                                OriginalGriffO Offline
                                OriginalGriffO Offline
                                OriginalGriff
                                wrote on last edited by
                                #23

                                Right: and what do you think that message means? Hint: What do you do immediately after you add the parameter values to sql_cmd ? (This is not a trick question)

                                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                A 2 Replies Last reply
                                0
                                • A ago2486

                                  System.Data.OleDb.OleDbException: 'No value given for one or more of the required parameters.'

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #24

                                  That cannot be true since there is no SQL command in the code you posted.

                                  1 Reply Last reply
                                  0
                                  • A ago2486

                                    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);
                                    
                                    Z Offline
                                    Z Offline
                                    ZurdoDev
                                    wrote on last edited by
                                    #25

                                    ago2486 wrote:

                                    'No value given for one or more of the required parameters.'

                                    That is not "some error", it tells you exactly what the problem is. You need to make sure you are submitting a value for all parameters.

                                    Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

                                    OriginalGriffO 1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      Right: and what do you think that message means? Hint: What do you do immediately after you add the parameter values to sql_cmd ? (This is not a trick question)

                                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                                      A Offline
                                      A Offline
                                      ago2486
                                      wrote on last edited by
                                      #26

                                      for me this message means that one of the values entered in the texbox is not loaded in the database suddenly it sees no data in the fields. I have the impression that my fields remain empty after adding

                                      1 Reply Last reply
                                      0
                                      • OriginalGriffO OriginalGriff

                                        Right: and what do you think that message means? Hint: What do you do immediately after you add the parameter values to sql_cmd ? (This is not a trick question)

                                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                                        A Offline
                                        A Offline
                                        ago2486
                                        wrote on last edited by
                                        #27

                                        I even tried this if, I have the same error

                                        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)";
                                        OleDbParameter refprod = sql_cmd.Parameters.AddWithValue("@ref_det", OleDbType.VarChar);
                                        refprod.Value = TxtRefProduit.Text;
                                        OleDbParameter qtecmd = sql_cmd.Parameters.AddWithValue("@qute_det", OleDbType.VarChar);
                                        qtecmd.Value = TxtQteCmd.Text;
                                        OleDbParameter design = sql_cmd.Parameters.AddWithValue("@Designation", OleDbType.VarChar);
                                        design.Value = TxtDesignation.Text;
                                        OleDbParameter prixU = sql_cmd.Parameters.AddWithValue("@Prix_unitaire_HT", OleDbType.Integer);
                                        prixU.Value = TxtPrixUnitaire.Text;
                                        OleDbParameter prixT = sql_cmd.Parameters.AddWithValue("@Prix_total_HT", OleDbType.Integer);
                                        prixT.Value = total;

                                                                   sql\_cmd = new OleDbCommand(txtQuery, sql\_con);
                                                                   sql\_cmd.ExecuteNonQuery();
                                                                  
                                                                }
                                        
                                        OriginalGriffO 1 Reply Last reply
                                        0
                                        • A ago2486

                                          I even tried this if, I have the same error

                                          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)";
                                          OleDbParameter refprod = sql_cmd.Parameters.AddWithValue("@ref_det", OleDbType.VarChar);
                                          refprod.Value = TxtRefProduit.Text;
                                          OleDbParameter qtecmd = sql_cmd.Parameters.AddWithValue("@qute_det", OleDbType.VarChar);
                                          qtecmd.Value = TxtQteCmd.Text;
                                          OleDbParameter design = sql_cmd.Parameters.AddWithValue("@Designation", OleDbType.VarChar);
                                          design.Value = TxtDesignation.Text;
                                          OleDbParameter prixU = sql_cmd.Parameters.AddWithValue("@Prix_unitaire_HT", OleDbType.Integer);
                                          prixU.Value = TxtPrixUnitaire.Text;
                                          OleDbParameter prixT = sql_cmd.Parameters.AddWithValue("@Prix_total_HT", OleDbType.Integer);
                                          prixT.Value = total;

                                                                     sql\_cmd = new OleDbCommand(txtQuery, sql\_con);
                                                                     sql\_cmd.ExecuteNonQuery();
                                                                    
                                                                  }
                                          
                                          OriginalGriffO Offline
                                          OriginalGriffO Offline
                                          OriginalGriff
                                          wrote on last edited by
                                          #28

                                          Please, look closely at your code. What does this line do exactly:

                                          sql_cmd = new OleDbCommand(txtQuery, sql_con);

                                          Not a trick question: Here it is as multiple choice: 1) Nothing 2) Throw away the existing content of the variable and replace it with a new, empty one. 3) Catch fire and die. 4) Create a new instance and assign all the old data to it. Extra hint: It's less than (3) and greater than (1).

                                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                          A 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups