Error Converting Data Type Numeric To Decimal In C#
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss error converting data type numeric to decimal sql server the workings and policies of this site About Us Learn more error converting data type numeric to decimal stored procedure about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow
Error Converting Data Type Varchar To Numeric Decimal
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
Arithmetic Overflow Error Converting Numeric To Data Type Numeric Decimal
other. Join them; it only takes a minute: Sign up Error converting from numeric data type to decimal up vote 0 down vote favorite Well here is my problem i have a table that contains the following column: asis_doc_minutos decimal(4,1) If i insert the following number (1.5) with a simple insert query it inserts it! BUT my SProcedure error converting data type nvarchar to numeric in c# doesn't inserts the data. Here is my Sp: ALTER procedure [dbo].[insertar_pla_asis_doc] @fecha datetime, @tema varchar(500), @minutos decimal(2,2), @cod_docente int, @cod_materia varchar(25), @cod_seccion int, @cod_ciclo int, @cod_escuela int as begin insert into pla_asis_doc(asis_doc_fecha, asis_doc_tema, asis_doc_fecha_realizo, asis_doc_cod_docente, asis_doc_cod_mat, asis_doc_seccion, asis_doc_cod_ciclo, asis_doc_cod_escuela, asis_doc_minutos) values (@fecha, @tema, getdate(), @cod_docente, @cod_materia, @cod_seccion, @cod_ciclo, @cod_escuela, @minutos); end I'm calling this Sp from C# and this is the way i do it: int valor_devuelto = puente.insertar(fecha, txtTema.Text, Convert.ToDecimal(lblHoras.Text), cod_emp, cod_materia, seccion, Convert.ToInt32(ciclo.Text), cod_esc); Notice that (lblHoras.Text) is called from a TextBox and so i convert it to Decimal becasue that's what my column expects. That lines calls to a method in another class, which is the one that calls my Sp in my db and where i got the error, here is that code: public int insertar(DateTime fecha, string tema, decimal minutos, int docente, string materia_codigo, int seccion, int ciclo, int escuela_cod) { int valor = 0; try { cn.Open(); cmd.Connection = cn; cmd.CommandText = "insertar_pla_asis_doc"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@fecha", System.Data.SqlDbType.DateTime).Value = fecha; cmd.Parameters.Add("@tema", System.Data.SqlDbType.VarChar).Value = tema; cmd.Parameters.Add("@minutos", System.Data.Sq
here for a quick overview of the site Help Center Detailed answers to any questions you might
Error Converting Data Type Numeric To Int
have Meta Discuss the workings and policies of this site About error converting data type varchar to numeric while inserting Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting error converting data type varchar to numeric union all 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 http://stackoverflow.com/questions/23348379/error-converting-from-numeric-data-type-to-decimal 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 http://stackoverflow.com/questions/2989983/sql-exception-error-converting-data-type-numeric-to-numeric 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() +137 Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016 If I use Red Gate SQL Compare to compare the staging
Studio 2015 products Visual Studio Team Services Visual Studio Code Visual Studio Dev Essentials Office Office Word/Excel/PowerPoint Microsoft Graph Outlook OneDrive/Sharepoint Skype Services Store Cortana Bing Application Insights Languages & platforms Xamarin ASP.NET C++ TypeScript .NET - VB, https://social.msdn.microsoft.com/Forums/windows/en-US/da71fd53-5b81-4272-80ae-c59e4fc6400f/sqlexception-error-converting-data-type-numeric-to-decimal?forum=winforms C#, F# Server Windows Server SQL Server BizTalk Server SharePoint Dynamics Programs & communities Students Startups Forums MSDN Subscriber downloads Sign in Search Microsoft Search Windows Dev Center Windows Dev Center Explore What’s new for http://www.codeproject.com/Questions/367195/Arithmetic-overflow-error-converting-numeric-to-da Windows 10 Intro to Universal Windows Platform Coding challenges Develop for accessibility Build for enterprise Windows Store opportunities Docs Windows apps Get started Design and UI Develop API reference Publish Monetize Promote Games Get started error converting UI design Develop Publish Desktop Get started Design Develop API reference Test and deploy Compatibility Windows IoT Microsoft Edge Windows Holographic Downloads Samples Support Why Windows Dashboard Explore What’s new for Windows 10 Intro to Universal Windows Platform Coding challenges Develop for accessibility Build for enterprise Windows Store opportunities Docs Windows apps Get started Design and UI Develop API reference Publish Monetize Promote Games Get started UI design Develop Publish Desktop error converting data Get started Design Develop API reference Test and deploy Compatibility Windows IoT Microsoft Edge Windows Holographic Downloads Samples Support Why Windows Dashboard Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: SqlException: Error converting data type numeric to decimal Windows Forms > Windows Forms General Question 0 Sign in to vote Hi, I have a table field which is decimal and defined as decimal(8, 7). When I am inserting values it accepts values less than 10 and when I start entering values 10 and above throwing me an error "Error converting data type numeric to decimal". I am really confused with this.. please help me. Friday, August 10, 2007 2:11 PM Reply | Quote Answers 2 Sign in to vote Hi, When you declare a decimal(8, 7) on Sql Server, it means the following: A decimal with 8 digits, 7 of them being after the decimal point Something like, 1.234567, but not 12,34567 because out of the 8 digits, 7 of them must be on the right hand side of the decimal point. If you want 8 digits and be able to represent 10, you'd need at least decimal(8, 6) Luc Friday, August 10, 2007 3:19 PM Reply
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ Arithmetic overflow error converting numeric to data type numeric. Rate this: Please Sign up or sign in to vote. See more: SQL-Server SQL-Server-2008 Hi experts, As per my understanding NUMERIC(18, 10)
column would take 18 decimal digits to the left of the decimal point and 10 to the right. One of our procedure started throwing 'Arithmetic overflow error converting numeric to data type numeric' error for much lesser values. I checked the documentation in msdn http://msdn.microsoft.com/en-us/library/ms187746.aspx[^] which also seems to say the same thing. Is there something I miss here? Example: SELECT CAST(1234567891234567.34 AS NUMERIC(18,2)) --Works SELECT CAST(1234567891234567.34 AS NUMERIC(18,10)) --fails with Arithmetic overflow error We fixed the problem by changing the casting to NUMERIC(18, 2)
but I wanted to unde