I have the following INSERT query being executed against an Access DB...
using (var cmd = conn.CreateCommand())
{
try
{
cmd.CommandText = @"INSERT INTO mtConcepts (
conceptid,
[text],
incomplete)
VALUES (
@conceptid,
@text,
false)";
cmd.Parameters.Add("@conceptid", OleDbType.BigInt).Value = concept.Id.Value;
cmd.Parameters.Add("@text", OleDbType.LongVarWChar).Value = cG.ToString(SaveOptions.DisableFormatting);
await cmd.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);
}
catch (AggregateException exception)
{
...
}
catch (OleDbException exception)
{
...
}
}
An OleDbException is caught with the message...
Too few parameters. Expected 2.
...and I can't understand why.
This is code which was written about 7 years ago and has worked until... sometime recently.
Furthermore, if I don't parameterise the query and instead pass the values directly in the SQL then it works.
Update
I got this working by installing an older version of the Microsoft Access Database Engine 2010 Redistributable. But still, I'm puzzled - before installing this 2010 version I was using the connection which comes with the latest version of Access (installed via Office365) so it should still have worked.