The following code under the .NET Core 3 causes the System.Data.OleDb.OleDbException: 'The parameter is incorrect.' exception, but under .NET Framework, it works fine:
Code
using (OleDbCommand command = new OleDbCommand()) {
command.Connection = connection;
command.CommandText = "insert into sales (id, units, cost_per_unit, discount, total_cost, sale_date, productId, RegionId, ChannelId, SectorId) values (@id, @units, @cost_per_unit, @discount, @total_cost, @sale_date, @productId, @RegionId, @ChannelId, @SectorId)";
command.Parameters.AddRange(
new OleDbParameter[] {
new OleDbParameter("@id", OleDbType.Integer),
new OleDbParameter("@units", OleDbType.Integer),
new OleDbParameter("@cost_per_unit", OleDbType.Integer),
new OleDbParameter("@discount", OleDbType.Integer),
new OleDbParameter("@total_cost", OleDbType.Integer),
new OleDbParameter("@sale_date", OleDbType.Date),
new OleDbParameter("@productId", OleDbType.Integer),
new OleDbParameter("@RegionId", OleDbType.Integer),
new OleDbParameter("@ChannelId", OleDbType.Integer),
new OleDbParameter("@SectorId", OleDbType.Integer)
}
);
command.Prepare();
Call Stack
System.Data.OleDb.dll!System.Data.OleDb.OleDbCommand.ProcessResults(System.Data.OleDb.OleDbHResult hr) Unknown
System.Data.OleDb.dll!System.Data.OleDb.OleDbCommand.ApplyParameterBindings(System.Data.Common.UnsafeNativeMethods.ICommandWithParameters commandWithParameters, System.Data.OleDb.tagDBPARAMBINDINFO[] bindInfo) Unknown
System.Data.OleDb.dll!System.Data.OleDb.OleDbCommand.CreateAccessor() Unknown
System.Data.OleDb.dll!System.Data.OleDb.OleDbCommand.InitializeCommand(System.Data.CommandBehavior behavior, bool throwifnotsupported) Unknown
System.Data.OleDb.dll!System.Data.OleDb.OleDbCommand.Prepare() Unknown
OleDbIssue.dll!OleDbIssue.SalesGenerator.Generate(System.Data.OleDb.OleDbConnection connection, System.DateTime startDate, int daysCount) Line 77 C#
OleDbIssue.dll!OleDbIssue.SalesGenerator.Run(string connectionString) Line 147 C#
OleDbIssue.dll!OleDbIssue.Program.Main(string[] args) Line 8 C#
The following code under the .NET Core 3 causes the System.Data.OleDb.OleDbException: 'The parameter is incorrect.' exception, but under .NET Framework, it works fine:
Code
Call Stack