NOTE: I have also posted this solution to : https://stackoverflow.com/questions/15760035/boolean-values-in-local-language/44321629#44321629
Hi,
I was "caught" too with this "issue".
Indeed, this is not an issue :
THE PROBLEM (EXAMPLE)
I had the same problem when using a boolean data in a SQL Statement.
On my French server, my SQL statement was the following :
<%
'Set my boolean value
Dim myBoolean
myBoolean = True
'Set my SQL Statement
Dim MySQLStatement
MySQLStatement = "SELECT * FROM MyTable WHERE MyBooleanField = " & myBoolean
'=> Here, as MySQLStatement is a STRING, the boolean data was "converted/rendered" as a localized string. So that leads to this output :
'=> SELECT * FROM MyTable WHERE MyBooleanField = Vrai
'Obviously, that SQL Statement is incorrect, because the SQL Engine does NOT understand what is the "Vrai" word - It should be "True" instead.
%>
THE EXPLANATIONS :
- It does not matter which regional settings are set on your Windows System : Nothing happens to the underlying data. A boolean data type is STILL a BOOLEAN, in English, or French, or German, Russian, Thai, ..or any language you want.
- The fact is that the data is simply being RENDERED as a localized STRING (like dates).
THE SOLUTION
After a lot of reading over forums threads, the solution is not to change regional settings on the Windows system, nor changing Registry keys, nor changing Session.LCID, ...
The absolute and code-only solution is to convert the Boolean value (True|False) to an Integer (0|1). Then, this Integer will be safely usable in a string, and will remain (0|1).
Here is the safe way to use/convert/render a Boolean value in a non-localized form : Use an Integer value.
<%
'Set my boolean value
Dim myBoolean
myBoolean = True
'Set my SQL Statement
Dim MySQLStatement
MySQLStatement = "SELECT * FROM MyTable WHERE MyBooleanField = " & BoolToInt(myBoolean)
'=> Here, as MySQLStatement is a STRING, and as the boolean data was previously "converted/rendered" as an integer, we got this correct SQL Statement :
'=> SELECT * FROM MyTable WHERE MyBooleanField = 1
'This SQL Statement is correct, as the SQL Engine DOES understand that 1 is a boolean.
'This Function Returns an INTEGER value based on a BOOLEAN value
Function BoolToInt(v)
'@param v Boolean The Input Boolean Value to be converted to an Integer
'@return i_OUT Integer The Output Integer Value (0|1)
'Convert the input value to a Boolean
Dim b_v : b_v = CBool(v)
'Define the Output Integer value
Dim i_OUT
'If the Input Boolean value is a "True" boolean value (in any language)
if (b_v) then
i_OUT = CInt(1)
'If the Input value is a "False" boolean value (in any language)
else
i_OUT = CInt(0)
end if
'Return
BoolToInt = i_OUT
End Function 'BoolToInt
%>
I really hope it save your day !