I'm approaching a access 2007 database using Microsoft.ACE.OLEDB.12.0. It contains a table created using
CREATE TABLE reccs(decimalField decimal(28,9))
which has to have this precision and scale. I'm adding a row using
string s = "INSERT INTO [reccs]([minQuantity]) VALUES(@minQuantity)";
object o = ...;
oleDbCommand = new OleDbCommand(s, conn);
OleDbParameter param = new OleDbParameter("minQuantity", o);
oleDbCommand.Parameters.Add(param).Value = o;
oleDbCommand.ExecuteNonQuery();
Sometimes (depending on the exact decimal in o) this throws a System.Data.OleDb.OleDbException: The decimal field's precision is too small to accept the numeric you attempted to add. I read this post, about adjusting decimal precision in c#, but it feels hacky to solve the problem like that, and I am unsure whether it will GUARANTEE that the exception will not get thrown. Any better suggestions?