"."and "," 
Author Message
 "."and ","
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?



Sat, 13 Oct 2001 03:00:00 GMT
 "."and ","

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?



Sun, 14 Oct 2001 03:00:00 GMT
 "."and ","

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



Sun, 14 Oct 2001 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. max of ("...","...","..")

2. The ""string""

3. "."and ","

4. What is difference between "=", "=*", "*=" in where clause

5. dbcc monitor("sample", "all", "on") does not populate master.dbo.sysmonitors on Solaris

6. ""URGENT "" Inserting "For xml explicit" results to a Temp table

7. how do I substitute(field, """, "")?

8. Record.open "", "URL=..."

9. aReport."Field".SetFilter("this")?

10. How to make a "decimal"-field to an "integer"-field

11. The+instruction+at+"0x1f90db9b"+referenced+memory+at+"0x7fa03794"+The+memory+cou


 
Powered by phpBB® Forum Software