Reputation: 105
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();
Upvotes: 1
Views: 63
Reputation: 415600
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.
Upvotes: 1