teixeira Posted December 12, 2006 Posted December 12, 2006 Hi I've a table in my SQL SERVER 2005 Express database with a couple of columns with decimal(4,2) data type, but when i try to insert a value on it, using the following stored procedure, i get this error: "Arithmetic overflow error converting numeric to data type numeric.", it's a kinda strange because the input value is ok, i think. So here's the SP: using (SqlCommand cmd = new SqlCommand()) { decimal qt = decimal.parse(qttTextBox.Text); cmd.Connection = DataBase.Conn;//Cria connection se n existir automaticamente cmd.CommandText = "spCriarLinhasPrescricao"; cmd.CommandType = CommandType.StoredProcedure; //Parametros SP cmd.Parameters.Clear(); cmd.Parameters.Add("@idMedicamento", SqlDbType.Int).Value = medicamentoId; cmd.Parameters.Add("@idPaciente", SqlDbType.Int).Value = pacienteId; cmd.Parameters.Add("@quant", SqlDbType.Decimal).Value = qt; //Here comes the error //Abre Conexão DataBase.Conn.Open(); cmd.ExecuteNonQuery(); //fecha Conexão DataBase.Conn.Close(); } Any help will be appreciated, TIA Tiago Teixeira Quote
teixeira Posted December 12, 2006 Author Posted December 12, 2006 Solved! Decimal(4,2) does not alows a value greater that 99.99 but decimal(6,2) solves my issue and i can then store 9999.99 regards, Tiago Teixeira Quote
*Experts* Nerseus Posted December 14, 2006 *Experts* Posted December 14, 2006 You may also want to investigate the "money" type. Decimal should work fine, but be careful to not make it too small - as you found out :) -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.