Page 2 of 2

Re: Strange numeric behavior

Posted: Sat Sep 21, 2013 7:08 pm
by Antonio Linares
Enrico,

This may help:
http://objectmix.com/c/398307-setlocaleinfo-how-make-effect-immeadiate.html

Code: Select all | Expand

bool SetDecimalSeparator(char Separator)
{
bool blRetVal = true;
char * pDecSep = new char[2];

GetLocaleInfo(GetSystemDefaultLCID(),LOCALE_SDECIMAL,pDecSep,2);

if(Separator == '.' && pDecSep[0] != '.')
{
if(!SetLocaleInfo(GetSystemDefaultLCID(), LOCALE_SDECIMAL, "."))
{
// PostMessage ??
blRetVal = false;
}
}
else if(Separator == ',' && pDecSep[0] != ',')
{
if(!SetLocaleInfo(GetSystemDefaultLCID(), LOCALE_SDECIMAL, ","))
{
// PostMessage ??
blRetVal = false;
}
}

delete[] pDecSep;
return blRetVal;
}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
SetDecimalSeparator('.');

}
 

Re: Strange numeric behavior

Posted: Sat Sep 21, 2013 7:28 pm
by Antonio Linares
This seems to be the message he is refering to:

PostMessage( HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0 )

Re: Strange numeric behavior

Posted: Sat Sep 21, 2013 8:08 pm
by Enrico Maria Giordano
Antonio,

it changes locale settings for all system. We surely don't want to do this. :-)

EMG

Re: Strange numeric behavior

Posted: Sat Sep 21, 2013 8:11 pm
by Enrico Maria Giordano
I found these:

Code: Select all | Expand

oCn:Properties( "Locale Identifier" ) = ...


or

Code: Select all | Expand

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyDatabase.mdb;Locale Identifier=...


but I didn't get them to work. :-(

EMG

Re: Strange numeric behavior

Posted: Sat Sep 21, 2013 8:31 pm
by Antonio Linares
Enrico,

This may help:
http://embarcadero.newsgroups.archived.at/public.delphi.database.ado/201004/1004281248.html

What I remember is, all Properties.Value must be in "string mode", even if
it's integer.
Another thing that I've found in my code, using hexa mode.

Try this

1044 --> 0x00000414

AdoConnection.Properties['Locale Identifier'].Value := '0x00000414';

Same thing under the connection string

'...;Locale Identifier=0x00000414;...'

Re: Strange numeric behavior

Posted: Sat Sep 21, 2013 9:19 pm
by Enrico Maria Giordano
Antonio,

tried all flavors: no success. :-(

EMG

Re: Strange numeric behavior

Posted: Sun Sep 22, 2013 2:27 pm
by nageswaragunupudi
I changed decimal symbol to "," and tested.
I confirm the problem with mdb and accdb.

Jet and Ace handle dbf also. There is no problem with dbf but only with Access.

It is not Locale. Whatever be the locale, it is only the "," that is creating the problem

Re: Strange numeric behavior

Posted: Sun Sep 22, 2013 3:02 pm
by Enrico Maria Giordano
I searched and searched Internet but found no solution... :-(

EMG