Error Converting Data Type Numeric To Decimal Asp.net
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Sql Exception: Error converting data type numeric to numeric [closed] up vote 6 down vote favorite We have a very strange issue with a database that has been moved from staging to production. The first time the database was moved it was by detaching, copying and reattaching, the second time we tried restoring from a backup of the staging. Both SQL Servers are the same version of MS SQL 2008, running on 64 bit hardware. The code accessing the database is the same build, built using the .net 2.0 framework. Here is the error message and some of the stack trace: Exception Details: System.Data.SqlClient.SqlException: Error converting data type numeric to numeric. Stack Trace: [SqlException (0x80131904): Error converting data type numeric to numeric.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1953274 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849707 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +204 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175 System.Data.SqlClient.SqlCommand.ExecuteNonQuery
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/Data Access/DataSource Controls - SqlDataSource, ObjectDataSource, etc/Error Converting Numeric to Decimal Error Converting Numeric to Decimal [Answered]RSS 3 replies Last http://stackoverflow.com/questions/2989983/sql-exception-error-converting-data-type-numeric-to-numeric post Mar 20, 2010 06:53 AM by Das.Sandeep ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Reply Bobby-Z http://forums.asp.net/t/1538234.aspx Participant 1906 Points 1212 Posts Error Converting Numeric to Decimal Mar 19, 2010 08:55 PM|Bobby-Z|LINK I have a feedback page with rating controls and I usea stored procedure to insert the record using C# I get an error when I try to insert about conversion. decimal varCurrentRating; decimal varDisplayRating; private void Calculate_Ratings() { varCurrentRating = ((Convert.ToDecimal(rateReliability.CurrentRating) + Convert.ToDecimal(rateBreakroomCleanliness.CurrentRating) + Convert.ToDecimal(rateCommunication.CurrentRating) + Convert.ToDecimal(rateDelivery.CurrentRating) + Convert.ToDecimal(rateExpectation.CurrentRating) + Convert.ToDecimal(rateFloorCare.CurrentRating) + Convert.ToDecimal(rateLobbyCleanliness.CurrentRating) + Convert.ToDecimal(rateLogbook.CurrentRating) + Convert.ToDecimal(rateOfficeCleanliness.CurrentRating) + Convert.ToDecimal(rateProblemResolution.CurrentRating) + Convert.ToDecimal(rateQuality.CurrentRating) + Convert.ToDecimal(rateReferrals.CurrentRating) + Convert.ToDecimal(rateRestroomCleanliness.CurrentRating) + Convert.ToDecimal(ratePaperProducts.CurrentRating) + Convert.ToDecimal(rateSecurity.CurrentRating) + Convert.ToDecimal(rateStaffKnowledge.CurrentRating) + Convert.ToDecimal(rateStaffProfessionalism.CurrentRating) + Convert.ToDecimal(rateSupplyCloset.CurrentRati
boasts of ‘information’ and ‘technology'.’ But alas, my pride is more stubborn than this. I have an application that is calling a procedure and it has a parameter with a decimal datatype. This error almost always has https://mattclingan.wordpress.com/2011/10/25/error-converting-data-type-numeric-to-decimal/ to do with your parameter setup in the stored procedure. I had my parameter sitting at decimal(2,2) and I was passing in a single number: 5. Now, should this work? You’d think so. Precision (the number of digits the object can hold) says, ‘two digits is fine with me’ and scale (number of digits to the right of the decimal point) states ‘hey, two digits after the decimal is GOOD!.’ But you are wrong. For error converting clarity let’s say my declaration stated decimal(3,2). This would mean only 3 numbers are allowed in the entire number (precision), and only 2 allowed after the decimal (scale). This would mean that only a single digit would be allowed prior to the decimal. So for 3,2 the number 1.55 would work. 12.55 would not. 1.556 would not. Palomino, Texas would not. Nor would an orange or a tomato or my older brother who still picks on error converting data me for that matter. So 1.55 would work for the declaration of (3,2). So what does that say about my declaration of (2,2)? For 2,2 I could only pass in fractions. Two numbers total are accepted and of those two numbers, two of them have to be to the right of the decimal. I was attempting to pass in a single number (5). I bumped my precision to 5 so that my parameter stored a parameter of decimal (5,2) and everything returned back to normal. Like this:Like Loading... Related Written by matt October 25, 2011 at 1:54 pm Posted in Asp.net, T-Sql « Quick and dirty: Sql Filestream Object – creating, inserting,displaying Poem: GenerateResourceNeverLockTypeAssemblies » Leave a Reply Cancel reply Enter your comment here... Fill in your details below or click an icon to log in: Email (required) (Address never made public) Name (required) Website You are commenting using your WordPress.com account. (LogOut/Change) You are commenting using your Twitter account. (LogOut/Change) You are commenting using your Facebook account. (LogOut/Change) You are commenting using your Google+ account. (LogOut/Change) Cancel Connecting to %s Notify me of new comments via email. Pages About Matt About this journal Search for: CategoriesCategories Select Category Asp.net(32) Batch(3) DevConnect2008(12) DevConnect2009(7) javascript(10) New to me(1) OffTopic(2) poetry(2) Report Services(11) Sql Performance(14) Sql Server(39) SSIS(20) T-Sql(59) Uncategorized(8) VB.net(14) VBA(2) vbscript(3) VSS(1) Archives