Formview gives Error converting data type nvarchar to numeric error when comma is in the input

I have a formview that collects various data including money and decimal data. I had a problem where the $ was casuing the "Error converting data type nvarchar to numeric" error and think I corrected it by changing the format to {0:C} for the field in the data bindings.

I am still having an issue with commas in the data in a decimal field. The field in the database is decimal (14,9) and the format in the textbox in the formview is {0:n}. The data being input is something like 123,456.0. This gives the Error converting data type nvarchar to numeric error. If you remove the comma, 123456.00, no error is received.

How do I fix this?

Thanks Ken

0
kterrell
6/8/2007 9:13:16 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

2 Replies
811 Views

Similar Articles

[PageSpeed] 36

 Consider the following TSQL fragment
DECLARE @FRED VARCHAR(50)
SET @FRED = '123,456.0'
DECLARE @DEC  DECIMAL(8,2)
SET @DEC = CONVERT(DECIMAL(8,2), REPLACE(@FRED, ',',''))
PRINT @DEC
This works because the comma is stripped prior to conversion. So change SELECT CONVERT(DECIMAL(8,2), FRED) .....
to SELECT
CONVERT(DECIMAL(8,2), REPLACE(FRED, ',','')) .......
where FRED is the column to display.


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
6/8/2007 10:11:05 PM

Not sure it was SQL that was blowing up. But I figured out what I had done before to get the money fields working. In the updateparamaters and the InsertParameters section, it did not have a type param for the text box field. I added the Type=decimal and it works correctly now.

<UpdateParameters>

<asp:Parameter Name="CompTypeId" Type="Int32" />

<asp:Parameter Name="CompName" Type="String" />

<asp:Parameter Name="Location" Type="String" />

<asp:Parameter Name="LegalDesc" Type="String" />

<asp:Parameter Name="TaxID" Type="String" />

<asp:Parameter Name="Grantor" Type="String" />

<asp:Parameter Name="Grantee" Type="String" />

<asp:Parameter Name="SaleDate" Type="DateTime" />

<asp:Parameter Name="SalePrice" />

<asp:Parameter Name="ListPrice" />

<asp:Parameter Name="LandSize" Type=Decimal />

<asp:Parameter Name="LandSizeUnitId" />

<asp:Parameter Name="ImproveSize" Type=decimal />

Thanks for the help.

0
kterrell
6/11/2007 2:01:50 PM
Reply:

Similar Artilces:

SQL Server Error: "Arithmetic overflow error converting numeric to data type numeric"
I'm still quite new to SQL, and so I may be missing something quite obvious. Apologies in advance if that's the case. I've included my query at the bottom of the message as it is quite long; my problem is that I get "Arithmetic overflow error converting numeric to data type numeric" when the first parameter to my COALESCE calls is not NULL. That is, the COALESCEs and the query work as I expect when SUM(cust_vw_actual.Actual) is NULL (they return 0.00), but if it isn't I get the error. I am also getting "Warning: Null value eliminated from aggregate.&...

Error converting data type nvarchar to numeric.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Error converting data type nvarchar to numeric.Source Error: Line 73: cmd1.Parameters.AddWithValue("@edate", edate); Line 74: cmd1.Parameters.AddWithValue("@phone", phone); Line 75: cmd1.ExecuteNonQuery(); Line 76: con.Close(); Line 77: How to solve this problem......

Session.LCID error: Error converting data type nvarchar to datetime
Hi! I got a SQL Server db with datetimes in tables in format as culture sv-SE. (2009-02-12 12:12:12) I also got a web application where I want to set culture based on membership profile info, but when I set culture en-GB I get the format on the datetimes as 20/02/2009 09:39:04. When handling datetimes against database I got "error converting data type nvarchar to datetime". Is it a work around for this so I can work with datetimes in one application with several cultures?  Hi,AimitU can do that with convert function ie convert that into 103 format&...

"Error converting data type nvarchar to numeric."
Hi  Im using the <asp:SqlDataSource to display a table in a datagrid. The data grid has AutoGenerateEditButton="True". I’m using this update command in the QslDataSource: UpdateCommand="UPDATE ShoeSize SET US = @US, Eur = @Eur, CM = @CM, Quant = @Quant, id = @id, UK = @UK  FROM ShoeSize WHERE IDroll = @IDroll" All the cells in the table is decimal(6,1) except ID, quant and IDroll witch are ints. But when I press update I get this error message: "Error converting data type nvarchar to numeric." I unde...

DropDown list to display DataList results in ERROR converting data type nvarchar to numeric ?
I have a drop down list populated with the below method, GetStaffListing. I'm trying to populate a datalist that uses GetStaffDataByProfile method to retrieve the data based on the profileid. I keep getting "coverting data type errors" when I run the webform.I experimented some and if I change the objectdatasource to an sqldatasource with this SQL, which is very similar to my method, it works fine.Here is the SQL for the sqldatasource.. SELECT [ProfileID], [StaffID], [BudgetYear], [Salary], [Grade], [GradeID], [InsuranceID], [Insurance], [LastName], [Suffix], [Degree], [MidName], [FirstName]...

Getting Server Error "Syntax error converting the nvarchar value 'Sonoma' to a column of data type int."
Hi, all I'm getting this error at runtime when my page tries to populate a datagrid. Here's the relevant code. First, the user selects his choice from a dropdownlist, populated with a sqldatasource control on the aspx side:<asp:SqlDataSource ID="sqlDataSourceCompany" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [PayrollCompanyID], [DisplayName] FROM [rsrc_PayrollCompany] ORDER BY [DisplayName]"> </asp:SqlDataSource>  And the dropdown list's code:<asp:DropDownList ID="ddlPayrol...

Error converting data type... Cannot find the error
I cannot figure out what is causing this error... The stored procedure works fins in the SQL database, but when I try to call it through the datasource I get the error at the bottom of the page... Can anyone help me figure out what this problem is? <asp:SqlDataSource ID="SqlDataSource1" runat="server"ConnectionString="<%$ ConnectionStrings:SqlServer %>"ProviderName="<%$ ConnectionStrings:SqlServer.ProviderName %>"SelectCommandType="StoredProcedure"CancelSelectOnNullParameter="false"SelectCommand="pe_getAppraisals3" ConflictDetection="CompareAllValues" SortParameterName...

Help needed: arithmetic overflow error converting numeric to data type numeric
Hi, I have a SQL server 2005 db. The table structure (from big list of columns, only decimal columns I mentioned) below.  CREATE TABLE [Product].[MetricMeasures](    [MetricMeasureID] [int] IDENTITY(1,1) NOT NULL,    [ProductID] [int] NOT NULL,    [ProductSizeValue] [decimal](4, 2) NULL,    [ItemWeightValue] [decimal](3, 3) NULL,    [MasterCartonWeightValue] [decimal](3, 3) NULL,    [MasterCartonVolumeValue] [decimal](4, 4) NULL, CONSTRAINT [PK_MetricMeasures] PRIMARY KEY CLUSTERED ( &nbs...

System.Data.SqlClient.SqlException: Error converting data type numeric to decimal.
Hi There, I'm using C# to get a value for a DOUBLE precision variable, called "Length", from a textBox using the following line: Length = Convert.ToDouble( txtLength.Text ) I'm also using the following lines to prepare my stored procedure call: arParms[9] = new SqlParameter("@Length", SqlDbType.Decimal, 5); arParms[9].Value = record.Length; My stored procedure has the following parameter definition: @Length decimal(9,3) My problem is that if someone types a value bigger than 999999 in the textbox he will get for sure the following error: System....

System.Data.SqlClient.SqlException: Error converting data type nvarchar to datetime.
I Receive this message when i add a Module to a page, What is wrong here? Are you using DNN 2.0? Are you using a core or 3rd party module (i.e. what module causes this error)? what are your globalization settings in the web.config? What are your current culture settings that you need to provide?Jeremy WhiteWebstone, LLCMy DNN Blog It's only happening when I include the module "EVENTS" into the portal. I donot use DNN 2.0 view post 479285Jeremy WhiteWebstone, LLCMy DNN Blog...

System.Data.SqlClient.SqlException: Error converting data type nvarchar to int.
I'm trying to implement encrypting/decrypting on a querystring (used this sample  http://www.devcity.net/Articles/47/1/encrypt_querystring.aspx)   .  However, now, my stored procedure doesn't work because it was expecting an integer, and now it's receiving the encrypted value and throws the error.  How do I tell my stored procedure to use a long encrypted value instead of the shorter integer it was expecting?    Do I cast it?  Do I convert it?  not sure what to do.. It used to be    UserID=123 Now it's somethi...

System.Data.SqlClient.SqlException: Error converting data type uniqueidentifier to nvarchar
I finally figure this out! Here is my blog: http://www.geekswithblogs.net/chrishan/archive/2005/07/16/47162.aspxIs there any other solution?http://www.bizsharp.com...

dwo.type for a data window that contains a button causes a system error -error accessing external object property type
When Rbuttondown event for u_dw is triggered it causes the pfc_u_dw Rbuttondown event to crash due to a dwo type problem ( a button on the data window ) . To see that put a button on the data window and press the rbmenu - pfc_u_dw rbuttondown event will cause a system error in line 45 . Line 45 if dwo.type <> "column" then return end if Any workarounds ? I suppose this is a PowerBuilder Bug that the PFC stumbles to . Thanks Ari Arthurs@tpg.com On Mon, 09 Mar 1998 14:54:04 GMT, in powersoft.public.powerbuilder.pfc arthurs@tpg.com wrote: >When Rbu...

Syntax error converting the nvarchar value 'no data' to a column of data type int
Hi all Here is an error I'm getting that I hope you can help with. Exception Details: System.Data.SqlClient.SqlException: Syntax error converting the nvarchar value 'no data' to a column of data type int. basically I'm trying to update a record using the Insert template in FormVeiw. The problem field is related to a  dropdownlist field that works as follows <asp:Label ID="LabelSchemeArea" runat="server" Visible="False" /> 'labelSchemeArea contains a value such as 1 or 2 or 3 <td style="width: 209px">Scheme...

Web resources about - Formview gives Error converting data type nvarchar to numeric error when comma is in the input - asp.net.object-datasource

Facebook Begins Converting Users To HTTPS
Are you willing to sacrifice a little bit of speed for a lot more safety? Facebook is asking that very question with its announcement that it ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Vert - simply converting for iPhone, iPad, and iPod touch on the iTunes App Store
Get Vert - simply converting on the App Store. See screenshots and ratings, and read customer reviews.

Converting SIM Card to Micro SIM Card - Flickr - Photo Sharing!
Place new Micro SIM into the iPhone SIM card tray

Ayaan Hirsi Ali on Converting Muslims to Christianity - YouTube
Complete video at: http://fora.tv/2010/07/29/Nomad_From_Islam_to_America_with_Ayaan_Hirsi_Ali Ayaan Hirsi Ali explains her support of missionary ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Converting Churches Into Homes Is The Latest Hollywood Trend
You don't have to be a believer to be moved by the beauty of a church.

Resources last updated: 12/18/2015 10:04:11 AM