"."and ","

"."and ","

Post by cat.. » Wed, 28 Apr 1999 04:00:00



Hi ,

we are devel.  a client/server app that uses VB + SQLServer 7.0. In some
cases our app aren't doing calcolations because  the WIN9X are setted to use
"," in "control panel"/"regional settings properties"/"Numbers"/"Decimal
symbol, instead ".".

THe case is that SQL saves the value with ","

Our client in VB will be used in many countries in the world.

How ro set SQLServer or VB to baypass the WIN settings?

 
 
 

"."and ","

Post by Andrea Lanfranch » Thu, 29 Apr 1999 04:00:00


This problem only happens under manipulation of
SQL strings. Something like

"INSERT INTO MyTable (MyValue) VALUES (" & mvarDouble & ")"

In this case if mvarDouble holds something like 125.38 the result
could be:

"INSERT INTO MyTable (MyValue) VALUES (125,38)"
and this is not acceptable as commas are delimiters of
values.

To workaround I use this small routine that fits the need

Public Static Function ReplaceChar(InputText As String, CharToReplace as
string, CharBeingReplaced as String) As String

    Dim sVarWorkString As String
Dim CharPos as Integer

CharPos = Instr(InputText, CharBeingReplaced)
Do while CharPos > 0
    if CharPos = 1 then
        InputText = CharToReplace & Mid$(InputText, 2)
    elseif CharPos = Len(InputText) then
        InputText = Mid$(InputText,1,CharPos-1) & CharToReplace
    else
        InputText = Mid$(InputText,1,CharPos-1) & CharToReplace &
Mid$(InputText,CharPos+1)
    end if
    CharPos = Instr(InputText, CharBeingReplaced)
Loop

ReplaceChar = InputText

End Function

So you sql string may be written as

"INSERT INTO MyTable (MyValue) VALUES (" &
ReplaceChar(Cstr(mvarDouble),".",",") & ")"
that will ALWAYS return:

"INSERT INTO MyTable (MyValue) VALUES (125.38)"

Hope This Helps and bye.


Quote:>Hi ,

>we are devel.  a client/server app that uses VB + SQLServer 7.0. In some
>cases our app aren't doing calcolations because  the WIN9X are setted to
use
>"," in "control panel"/"regional settings properties"/"Numbers"/"Decimal
>symbol, instead ".".

>THe case is that SQL saves the value with ","

>Our client in VB will be used in many countries in the world.

>How ro set SQLServer or VB to baypass the WIN settings?


 
 
 

"."and ","

Post by Chat » Thu, 29 Apr 1999 04:00:00


"SELECT * FROM Table WHERE Value = " & STR(VarDouble)