Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Detailsview shows real numbers with commata: Error converting data type nvarchar to real!

Reply
Thread Tools

Detailsview shows real numbers with commata: Error converting data type nvarchar to real!

 
 
Curious Trigger
Guest
Posts: n/a
 
      09-09-2006
Hello,

if have an asp.net web page with a detailsview. This detailsview uses a
sqldatasource connecting to a sql server 2005 database with a select
statement simliar to this one:

SELECT warning_threshold, critical_threshold, weight FROM thresholds
UPDATE thresholds SET warning_threshold=@warning_threshold,
critical_threshold=@critical_threshold, weight =@weight
I also added insert and delete statements to this datasource.

The fields warning_threshold, critical_threshold and weight are of sql-type
real and contain figures between 0.00 and 1.00 (e.g 0.85).

In the gridview those figures are shown with commata (0,85) and if I try to
update the dataset I get thist error:

"Error converting data type nvarchar to real!"

How I can ensure that all real-numbers are shown with a decimal point
instead of a comma?
And how can I asure that the user can enter only decimal points too?

Thank you very much for any advice!

Yours,
Mathias


 
Reply With Quote
 
 
 
 
Rob MacFadyen
Guest
Posts: n/a
 
      09-09-2006
Mathias,

Formatting is controlled by the cultural settings. If you've set an explicit
UI culture, or indicated an auto culture, or the server's inherient culture
uses a "european" numeric formatting (eg. 999 999,99) then what you are
seeing is the expected behavior.

You could force the culture in the web.config file:
<configuration>
<system.web>
<globalization
requestencoding="utf-8"
responseencoding=" utf-8"
fileencoding=" utf-8"
culture="de-DE"
uiculture="en" />
</system.web>
</configuration>


On a per page basis you can specify the culture:

<%@ Page Culture="ja-JP" UICulture="ja" ResponseEncoding="utf-8"%>



And you can do it with code:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");


You can also fish out the name of the current culture:

Thread.CurrentThread.CurrentCulture.EnglishName


Does any of that help?

Regards,

Rob MacFadyen


"Curious Trigger" <(E-Mail Removed)> wrote in message
news:%23$AgLO$(E-Mail Removed)...
> Hello,
>
> if have an asp.net web page with a detailsview. This detailsview uses a
> sqldatasource connecting to a sql server 2005 database with a select
> statement simliar to this one:
>
> SELECT warning_threshold, critical_threshold, weight FROM thresholds
> UPDATE thresholds SET warning_threshold=@warning_threshold,
> critical_threshold=@critical_threshold, weight =@weight
> I also added insert and delete statements to this datasource.
>
> The fields warning_threshold, critical_threshold and weight are of
> sql-type real and contain figures between 0.00 and 1.00 (e.g 0.85).
>
> In the gridview those figures are shown with commata (0,85) and if I try
> to update the dataset I get thist error:
>
> "Error converting data type nvarchar to real!"
>
> How I can ensure that all real-numbers are shown with a decimal point
> instead of a comma?
> And how can I asure that the user can enter only decimal points too?
>
> Thank you very much for any advice!
>
> Yours,
> Mathias
>



 
Reply With Quote
 
 
 
 
Curious Trigger
Guest
Posts: n/a
 
      09-09-2006
Hi Rob,

thank you very much! I changed my web.config and that solved my problem.
I couldn't simply cut and paste your text, because in web.config you have to
pay attention to lower-case and upper-case letters and leading spaces (e.g.
"utf-8" instead of " utf-8").
So I adopted it like this:

<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
fileEncoding="utf-8"
culture="en-US"
uiCulture="en" />

Regards,
Mathias

"Rob MacFadyen" <rmacfadyen_at_gmail.com> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Mathias,
>
> Formatting is controlled by the cultural settings. If you've set an
> explicit UI culture, or indicated an auto culture, or the server's
> inherient culture uses a "european" numeric formatting (eg. 999 999,99)
> then what you are seeing is the expected behavior.
>
> You could force the culture in the web.config file:
> <configuration>
> <system.web>
> <globalization
> requestencoding="utf-8"
> responseencoding=" utf-8"
> fileencoding=" utf-8"
> culture="de-DE"
> uiculture="en" />
> </system.web>
> </configuration>
>
>
> On a per page basis you can specify the culture:
>
> <%@ Page Culture="ja-JP" UICulture="ja" ResponseEncoding="utf-8"%>
>
>
>
> And you can do it with code:
>
> Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
>
>
> You can also fish out the name of the current culture:
>
> Thread.CurrentThread.CurrentCulture.EnglishName
>
>
> Does any of that help?
>
> Regards,
>
> Rob MacFadyen
>
>
> "Curious Trigger" <(E-Mail Removed)> wrote in message
> news:%23$AgLO$(E-Mail Removed)...
>> Hello,
>>
>> if have an asp.net web page with a detailsview. This detailsview uses a
>> sqldatasource connecting to a sql server 2005 database with a select
>> statement simliar to this one:
>>
>> SELECT warning_threshold, critical_threshold, weight FROM thresholds
>> UPDATE thresholds SET warning_threshold=@warning_threshold,
>> critical_threshold=@critical_threshold, weight =@weight
>> I also added insert and delete statements to this datasource.
>>
>> The fields warning_threshold, critical_threshold and weight are of
>> sql-type real and contain figures between 0.00 and 1.00 (e.g 0.85).
>>
>> In the gridview those figures are shown with commata (0,85) and if I try
>> to update the dataset I get thist error:
>>
>> "Error converting data type nvarchar to real!"
>>
>> How I can ensure that all real-numbers are shown with a decimal point
>> instead of a comma?
>> And how can I asure that the user can enter only decimal points too?
>>
>> Thank you very much for any advice!
>>
>> Yours,
>> Mathias
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error converting data type nvarchar to numeric Adam_Cogswell ASP .Net 1 02-29-2008 04:12 PM
Incorrect syntax near 'nvarchar'. Kevin Bilbee ASP .Net 5 01-27-2008 10:33 PM
Problem with field type nvarchar(max) maurox ASP General 3 01-17-2007 04:22 PM
[SqlException (0x80131904): Error converting data type decimal to nvarchar.] gvt99@hotmail.com ASP .Net Web Controls 0 12-22-2005 12:00 AM
about nvarchar( number ) mike ASP .Net 1 11-24-2005 10:05 AM



Advertisments