PC Review


Reply
Thread Tools Rate Thread

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

 
 
Curious Trigger
Guest
Posts: n/a
 
      9th Sep 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
 
      9th Sep 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
 
      9th Sep 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
Rate This Thread
Rate This Thread:

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 Microsoft ASP .NET 1 29th Feb 2008 04:12 PM
Casting integer type to real state in a DetailsView Jason Huang Microsoft C# .NET 1 14th Jun 2007 05:35 AM
Converting String numbers into real numbers Werner Microsoft Excel Programming 1 27th Jun 2005 09:41 PM
Converting String numbers into real numbers Jean-Jérôme Doucet via OfficeKB.com Microsoft Excel Programming 2 27th Jun 2005 03:30 PM
Error converting data type nvarchar to datetime - Please help Andrew Baker Microsoft VB .NET 1 2nd Jul 2004 07:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:38 AM.