Home All Groups Group Topic Archive Search About

Urgent!...SQL Server cannot handle "CDEC" in web application

Author
26 Feb 2007 10:55 PM
_YES
Please, can sombody help me with this problem.

I have created a web application, in visual studio 2005 professional. This
application needs to convert some string values, from an externally stored
SQL database table, to decimals. When the application has been compiled and
is running locally in the computer everything works fine, all calculations in
the application end up correctly.

The problem comes when the application  is running at the web server (an
extern SQL Server), then all calculations goes wrong, badly wrong!!!

0,46 * 0,56  ---> 0
123,456   --->   123456

and so on...  Why??

------------------------
Example, calculation from code:

tSum = Round(totSum + (NullSafeDecimal(reader.Item("column1")) *
NullSafeDecimal(reader.Item("column2"))), 2)

'****************************************************
    ' NullSafeDecimal
'****************************************************
    Public Shared Function NullSafeDecimal(ByVal arg As Object, _
      Optional ByVal returnIfEmpty As Integer = 0) As Decimal

        Dim returnValue As Decimal

        If (arg Is DBNull.Value) OrElse (arg Is Nothing) _
                         OrElse (arg Is String.Empty) Then
            returnValue = False
        Else
            Try
                returnValue = CDec(arg)
            Catch
                returnValue = False
            End Try
        End If

        Return returnValue

    End Function

Author
27 Feb 2007 1:19 AM
Patrick Steele
In article <A09265B7-AC56-4ECB-A0A9-FB22783E3***@microsoft.com>,
Y**@discussions.microsoft.com says...
> I have created a web application, in visual studio 2005 professional. This
> application needs to convert some string values, from an externally stored
> SQL database table, to decimals. When the application has been compiled and
> is running locally in the computer everything works fine, all calculations in
> the application end up correctly.
>
> The problem comes when the application  is running at the web server (an
> extern SQL Server), then all calculations goes wrong, badly wrong!!!
>  
> 0,46 * 0,56  ---> 0
> 123,456   --->   123456
>
> and so on...  Why??

Are the regional settings for both machines exactly the same?


AddThis Social Bookmark Button