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

Discussion in 'ASP .Net' started by Curious Trigger, Sep 9, 2006.

  1. 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
     
    Curious Trigger, Sep 9, 2006
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%23$AgLO$...
    > 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
    >
     
    Rob MacFadyen, Sep 9, 2006
    #2
    1. Advertising

  3. 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:...
    > 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" <> wrote in message
    > news:%23$AgLO$...
    >> 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
    >>

    >
    >
     
    Curious Trigger, Sep 9, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gce
    Replies:
    0
    Views:
    796
  2. Adam_Cogswell
    Replies:
    1
    Views:
    6,197
    Adam_Cogswell
    Feb 29, 2008
  3. Replies:
    0
    Views:
    1,027
  4. maurox

    Problem with field type nvarchar(max)

    maurox, Jan 17, 2007, in forum: ASP General
    Replies:
    3
    Views:
    211
    maurox
    Jan 17, 2007
  5. Gianni

    IE shows false and Firefox shows true

    Gianni, Jul 10, 2009, in forum: Javascript
    Replies:
    3
    Views:
    493
    Thomas 'PointedEars' Lahn
    Jul 10, 2009
Loading...

Share This Page