1

I have problem when updating data using OleDb in C#. Error says

No value given for one or more required parameters.

Here my code

OleDbConnection kon = new OleDbConnection(koneksi);
            OleDbCommand command = kon.CreateCommand();

            kon.Open();

            if (LimitCB.SelectedItem == "30")
            {
                command.CommandText = "UPDATE [Data] SET [Denom 50]= @den50, [Denom 100]= @den100 WHERE [Limit] = @lim30";
                command.Parameters.AddWithValue("@den50", CRMden50.Text);
                command.Parameters.AddWithValue("@den100", CRMden100.Text);
                command.Parameters.AddWithValue("@lim30", 30);
                command.ExecuteNonQuery();
            }  
            kon.Close();
2
  • [Denom 50] and [Denom 100] are your columns names within table? Commented Feb 7, 2017 at 4:08
  • Yes they are @MAdeelKhalid Commented Feb 7, 2017 at 4:49

1 Answer 1

1

OleDb does not have named parameters. From the first sentence in the Remarks section of the documentation:

The OLE DB .NET Provider does not support named parameters for passing parameters to an SQL statement

Instead of @name, it uses the ? token as parameter placesholders and relies on the ordering of the parameters in the collection to match parameter values to the placeholder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.