Regional Settings Problem / SQLCE money Type

F

Felipe T

Hi guys,
im having a problem with CF and SQLCE.
ill try to explain it:

The Decimal Value in VB.Net(with regional settings to english) is something
like 10.98, it uses the dot to split the decimal part. In the VB.NET i work
fine with this value.

When i convert 10.98 i got 10,98 cuz my regional settings is pointed to
Portuguese(Brasil). When i try to record the 10,98 in the SQLCE money field,
it brings me and error.
I was sending the 10.98, and got no problem. But with the 10,98 in the
string the SQLCE assumes that there are two fields.
Anyone knows how to send values to SQLCE expliciting they r money values?
Or to change the regional Settings logically?
Or any other way to do such thing?

Thanks,
Felipe
 
M

Mark Johnson

You have this problem also on many other European Cultures.
On the PC I switch to US-Culture when Formatting SQL-Strings, but on Compact
does not support this.
So, hoping nobody will use "1.123,45" I have the following code :

if (dset_Table.Columns.DataType == typeof(System.Decimal)) //
Decimal
{ // In Germany we have different sign for Decimal Point, but SqlCe
does not like that
System.Text.RegularExpressions.Regex r2 = new
System.Text.RegularExpressions.Regex(",");
s_DataType = r2.Replace(s_DataType,"."); // Replace , with .
} // if (dset_Table.Columns.DataType == typeof(System.Decimal))
// Decimal
if (dset_Table.Columns.DataType == typeof(System.Double)) //
Double
{ // In Germany we have different sign for Decimal Point, but SqlCe
does not like that
System.Text.RegularExpressions.Regex r2 = new
System.Text.RegularExpressions.Regex(",");
s_DataType = r2.Replace(s_DataType,"."); // Replace , with .
} // if (dset_Table.Columns.DataType == typeof(System.Double))
// Double

Mark Johnson, Berlin Germany
(e-mail address removed)
 
F

Felipe T.

Yeah, Yeah.
Maybe i could try to use the namespace:
System.Globalization

Using:
NumberFormatInfo.CurrentInfo.NumberDecimalSeparator
and
NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator
.....
yeah, ill try them
 
R

Roman Batoukov [MS]

You can use custom format providers when converting number to a string.
Typically it's NumberFormatInfo instance, typically retrieved from
CultureInfo class. By default, your current culture(locale), conventions
will be used. But you may use arbitrary NumberFormatInfo as format
provider. You may override individual fields of NumberFormatInfo, such as
decimal separator.
Please note that current CultureInfo is also sensitive to user overrides -
so if you change your decimal separator via device Regional Options, it'll
be reflected in the instance of the CultureInfo.CurrentCulture.

- Roman
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
| From: "Felipe T." <[email protected]>
| References: <[email protected]>
| Subject: Re: Regional Settings Problem / SQLCE money Type
| Date: Fri, 23 Jan 2004 16:33:50 -0300
| Lines: 34
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 200.244.33.250
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:43878
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Yeah, i can get the values, but i cant write on them....
| Anyone can help?
|
|
| | > Hi guys,
| > im having a problem with CF and SQLCE.
| > ill try to explain it:
| >
| > The Decimal Value in VB.Net(with regional settings to english) is
| something
| > like 10.98, it uses the dot to split the decimal part. In the VB.NET i
| work
| > fine with this value.
| >
| > When i convert 10.98 i got 10,98 cuz my regional settings is pointed to
| > Portuguese(Brasil). When i try to record the 10,98 in the SQLCE money
| field,
| > it brings me and error.
| > I was sending the 10.98, and got no problem. But with the 10,98 in the
| > string the SQLCE assumes that there are two fields.
| > Anyone knows how to send values to SQLCE expliciting they r money
values?
| > Or to change the regional Settings logically?
| > Or any other way to do such thing?
| >
| > Thanks,
| > Felipe
| >
| >
| >
| >
|
|
|

This posting is provided "AS IS" with no warranties, and confers no rights.
 
F

Felipe T.

Hi guys,
Im still trying, and got no success. Mark, ive tryed ur code, but the number
becames an integer with the comma, and a decimal with the point. The problem
is that the Decimal Data Type is somewhat diferent(by decimal separator) of
the money data type of SqlCE. I could use a string in my code instead of
using decimal, but...I do not want to do that, the code would became a bit
strange, so i discarded this option.
Anyway, ill keep on trying.

Thanks


----- Original Message -----
From: "Mark Johnson" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
Sent: Friday, January 23, 2004 3:43 PM
Subject: Re: Regional Settings Problem / SQLCE money Type

You have this problem also on many other European Cultures.
On the PC I switch to US-Culture when Formatting SQL-Strings, but on Compact
does not support this.
So, hoping nobody will use "1.123,45" I have the following code :

if (dset_Table.Columns.DataType == typeof(System.Decimal)) //
Decimal
{ // In Germany we have different sign for Decimal Point, but SqlCe
does not like that
System.Text.RegularExpressions.Regex r2 = new
System.Text.RegularExpressions.Regex(",");
s_DataType = r2.Replace(s_DataType,"."); // Replace , with .
} // if (dset_Table.Columns.DataType == typeof(System.Decimal))
// Decimal
if (dset_Table.Columns.DataType == typeof(System.Double)) //
Double
{ // In Germany we have different sign for Decimal Point, but SqlCe
does not like that
System.Text.RegularExpressions.Regex r2 = new
System.Text.RegularExpressions.Regex(",");
s_DataType = r2.Replace(s_DataType,"."); // Replace , with .
} // if (dset_Table.Columns.DataType == typeof(System.Double))
// Double

Mark Johnson, Berlin Germany
(e-mail address removed)




Felipe T said:
Hi guys,
im having a problem with CF and SQLCE.
ill try to explain it:

The Decimal Value in VB.Net(with regional settings to english) is something
like 10.98, it uses the dot to split the decimal part. In the VB.NET i work
fine with this value.

When i convert 10.98 i got 10,98 cuz my regional settings is pointed to
Portuguese(Brasil). When i try to record the 10,98 in the SQLCE money field,
it brings me and error.
I was sending the 10.98, and got no problem. But with the 10,98 in the
string the SQLCE assumes that there are two fields.
Anyone knows how to send values to SQLCE expliciting they r money values?
Or to change the regional Settings logically?
Or any other way to do such thing?

Thanks,
Felipe
 
S

Selahattin TASPINAR

SQLCE doesn't accept regional settings to format numbers

So I've tried this code for Turkish Regional Settings and it is running...

NumberFormatInfo nfi = new CultureInfo( "tr-TR", false ).NumberFormat;
//Displays a value with the default separator (",").
Decimal myDec = (decimal)123489.98;
MessageBox.Show( myDec.ToString( "N", nfi ) );
// Displays the same value with a . as the separator.
// and , as group separator
nfi.NumberDecimalSeparator = ".";
nfi.NumberGroupSeparator = ",";
MessageBox.Show( myDec.ToString( "N", nfi ) );

You can apply the same logic for money as well...



Felipe T. said:
Hi guys,
Im still trying, and got no success. Mark, ive tryed ur code, but the number
becames an integer with the comma, and a decimal with the point. The problem
is that the Decimal Data Type is somewhat diferent(by decimal separator) of
the money data type of SqlCE. I could use a string in my code instead of
using decimal, but...I do not want to do that, the code would became a bit
strange, so i discarded this option.
Anyway, ill keep on trying.

Thanks


----- Original Message -----
From: "Mark Johnson" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
Sent: Friday, January 23, 2004 3:43 PM
Subject: Re: Regional Settings Problem / SQLCE money Type

You have this problem also on many other European Cultures.
On the PC I switch to US-Culture when Formatting SQL-Strings, but on Compact
does not support this.
So, hoping nobody will use "1.123,45" I have the following code :

if (dset_Table.Columns.DataType == typeof(System.Decimal)) //
Decimal
{ // In Germany we have different sign for Decimal Point, but SqlCe
does not like that
System.Text.RegularExpressions.Regex r2 = new
System.Text.RegularExpressions.Regex(",");
s_DataType = r2.Replace(s_DataType,"."); // Replace , with .
} // if (dset_Table.Columns.DataType == typeof(System.Decimal))
// Decimal
if (dset_Table.Columns.DataType == typeof(System.Double)) //
Double
{ // In Germany we have different sign for Decimal Point, but SqlCe
does not like that
System.Text.RegularExpressions.Regex r2 = new
System.Text.RegularExpressions.Regex(",");
s_DataType = r2.Replace(s_DataType,"."); // Replace , with .
} // if (dset_Table.Columns.DataType == typeof(System.Double))
// Double

Mark Johnson, Berlin Germany
(e-mail address removed)




Felipe T said:
Hi guys,
im having a problem with CF and SQLCE.
ill try to explain it:

The Decimal Value in VB.Net(with regional settings to english) is something
like 10.98, it uses the dot to split the decimal part. In the VB.NET i work
fine with this value.

When i convert 10.98 i got 10,98 cuz my regional settings is pointed to
Portuguese(Brasil). When i try to record the 10,98 in the SQLCE money field,
it brings me and error.
I was sending the 10.98, and got no problem. But with the 10,98 in the
string the SQLCE assumes that there are two fields.
Anyone knows how to send values to SQLCE expliciting they r money values?
Or to change the regional Settings logically?
Or any other way to do such thing?

Thanks,
Felipe


Felipe T said:
Hi guys,
im having a problem with CF and SQLCE.
ill try to explain it:

The Decimal Value in VB.Net(with regional settings to english) is something
like 10.98, it uses the dot to split the decimal part. In the VB.NET i work
fine with this value.

When i convert 10.98 i got 10,98 cuz my regional settings is pointed to
Portuguese(Brasil). When i try to record the 10,98 in the SQLCE money field,
it brings me and error.
I was sending the 10.98, and got no problem. But with the 10,98 in the
string the SQLCE assumes that there are two fields.
Anyone knows how to send values to SQLCE expliciting they r money values?
Or to change the regional Settings logically?
Or any other way to do such thing?

Thanks,
Felipe
 
F

Felipe T.

This solvd,
Thanx for everybody.

Selahattin TASPINAR said:
SQLCE doesn't accept regional settings to format numbers

So I've tried this code for Turkish Regional Settings and it is running...

NumberFormatInfo nfi = new CultureInfo( "tr-TR", false ).NumberFormat;
//Displays a value with the default separator (",").
Decimal myDec = (decimal)123489.98;
MessageBox.Show( myDec.ToString( "N", nfi ) );
// Displays the same value with a . as the separator.
// and , as group separator
nfi.NumberDecimalSeparator = ".";
nfi.NumberGroupSeparator = ",";
MessageBox.Show( myDec.ToString( "N", nfi ) );

You can apply the same logic for money as well...



"Felipe T." <[email protected]> wrote in message
Hi guys,
Im still trying, and got no success. Mark, ive tryed ur code, but the number
becames an integer with the comma, and a decimal with the point. The problem
is that the Decimal Data Type is somewhat diferent(by decimal separator) of
the money data type of SqlCE. I could use a string in my code instead of
using decimal, but...I do not want to do that, the code would became a bit
strange, so i discarded this option.
Anyway, ill keep on trying.

Thanks


----- Original Message -----
From: "Mark Johnson" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
Sent: Friday, January 23, 2004 3:43 PM
Subject: Re: Regional Settings Problem / SQLCE money Type

You have this problem also on many other European Cultures.
On the PC I switch to US-Culture when Formatting SQL-Strings, but on Compact
does not support this.
So, hoping nobody will use "1.123,45" I have the following code :

if (dset_Table.Columns.DataType == typeof(System.Decimal)) //
Decimal
{ // In Germany we have different sign for Decimal Point, but SqlCe
does not like that
System.Text.RegularExpressions.Regex r2 = new
System.Text.RegularExpressions.Regex(",");
s_DataType = r2.Replace(s_DataType,"."); // Replace , with .
} // if (dset_Table.Columns.DataType == typeof(System.Decimal))
// Decimal
if (dset_Table.Columns.DataType == typeof(System.Double)) //
Double
{ // In Germany we have different sign for Decimal Point, but SqlCe
does not like that
System.Text.RegularExpressions.Regex r2 = new
System.Text.RegularExpressions.Regex(",");
s_DataType = r2.Replace(s_DataType,"."); // Replace , with .
} // if (dset_Table.Columns.DataType == typeof(System.Double))
// Double

Mark Johnson, Berlin Germany
(e-mail address removed)




Hi guys,
im having a problem with CF and SQLCE.
ill try to explain it:

The Decimal Value in VB.Net(with regional settings to english) is something
like 10.98, it uses the dot to split the decimal part. In the VB.NET
i
work
fine with this value.

When i convert 10.98 i got 10,98 cuz my regional settings is pointed to
Portuguese(Brasil). When i try to record the 10,98 in the SQLCE
money
field,
it brings me and error.
I was sending the 10.98, and got no problem. But with the 10,98 in the
string the SQLCE assumes that there are two fields.
Anyone knows how to send values to SQLCE expliciting they r money values?
Or to change the regional Settings logically?
Or any other way to do such thing?

Thanks,
Felipe

Felipe T said:
Hi guys,
im having a problem with CF and SQLCE.
ill try to explain it:

The Decimal Value in VB.Net(with regional settings to english) is something
like 10.98, it uses the dot to split the decimal part. In the VB.NET i work
fine with this value.

When i convert 10.98 i got 10,98 cuz my regional settings is pointed to
Portuguese(Brasil). When i try to record the 10,98 in the SQLCE money field,
it brings me and error.
I was sending the 10.98, and got no problem. But with the 10,98 in the
string the SQLCE assumes that there are two fields.
Anyone knows how to send values to SQLCE expliciting they r money values?
Or to change the regional Settings logically?
Or any other way to do such thing?

Thanks,
Felipe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top