.ToString produces different result on 1/4 servers

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Using the .ToString method on a SQL 2000 money data type
field of a dataset produces different results depending
on which server I execute the same code against the same
data. In the example below 3 servers produce '14.99' and
1 server produces '14.9900'. OS, Framework version (1.1),
and regional setings of the server appear to be the same
as the others.

Code and results below....

VB.NET Code...

Public Sub BuildLoadItemArray(ByVal Rows As
DataRowCollection)
Dim drRow As DataRow
Dim sbText As New StringBuilder(vbCrLf)

For Each drRow In Rows
'Added to not show 8.97 items in categories other
than ESAL (11)
If CategoryID = 11 OrElse drRow.Item
("Price").ToString <> "8.97" Then
With drRow
sbText.Append(" If (SortID = 1) Or (dPrice
= " & .Item("Price").ToString & "D) Then" & vbCrLf)
sbText.Append(" With uItemRecord" & vbCrLf)
sbText.Append(" .ItemID = " & .Item
("ItemID").ToString & vbCrLf)
sbText.Append(" .ItemName = """ & .Item
("Name").ToString.Trim.Replace("""", """""") & """" &
vbCrLf)
sbText.Append(" .Price = " & .Item
("Price").ToString & "D" & vbCrLf)
sbText.Append(" .ThumbnailImage = """
& .Item("ThumbnailImage").ToString.Trim & """" & vbCrLf)
sbText.Append(" .PartNumber = """ & .Item
("PartNo").ToString.Trim & """" & vbCrLf)
sbText.Append(" End With" & vbCrLf &
vbCrLf)
sbText.Append(" ItemArray.Add
(uItemRecord)" & vbCrLf)
sbText.Append(" End If" & vbCrLf & vbCrLf)
Application.DoEvents()
End With
End If
Next drRow

LoadItemArray = sbText.ToString
End Sub

--------------------------

Results...

1 server produces...

If (SortID = 1) Or (dPrice = 14.9900D) Then
With uItemRecord
.ItemID = 2877
.ItemName = "SLED COFFEE TABLE"
.Price = 14.9900D
.ThumbnailImage = "tn_33028.jpg"
.PartNumber = "33028"
End With

ItemArray.Add(uItemRecord)
End If


3 servers produce..

If (SortID = 1) Or (dPrice = 14.99D) Then
With uItemRecord
.ItemID = 2877
.ItemName = "SLED COFFEE TABLE"
.Price = 14.99D
.ThumbnailImage = "tn_33028.jpg"
.PartNumber = "33028"
End With

ItemArray.Add(uItemRecord)
End If
 
Hi Brian,

I think ToString will format values based on local international settings on
your PCs, not settings on a server side. Check local settings
 
Looks to be a difference between .NET Framework v1.0 vs
v1.1

The application was compiled with System and System.Data
references to version 1.0.

The server in question only had version 1.1 installed -
the other three had both v1.0 and v1.1 installed (so they
used the v1.0 references).

I have not seen any Microsoft acticles referring to this
difference between the versions, but installing Framework
v1.0 solved the discrepancy.
 
Back
Top