Home All Groups Group Topic Archive Search About

definining currency in ADO.NET 2.0

Author
6 Nov 2006 12:23 AM
Andre Ranieri
I have a procedural question - in ADO.NET 1.1 when I created DataSets from an
XSD schema I would create a SimpleType named "Money" and set the
FractionDigits to 2.  Thus, my USD fields were always correctly formated
$1.23.

In ADO.NET 2.0 (at least from the IDE) I don't seem to be able to specify a
simple type in my schema, or much of anything else for that matter.  What is
the recommended method for locking dataset values to currency format?

Thanks in advance,  I apologize but some of the changes ADO.NET 2.0 aren't
making sense yet.

Andre Ranieri

Author
6 Nov 2006 4:34 AM
Cor Ligthert [MVP]
Anre,

Some like it, some don't "decimal"

Cor

Show quote
"Andre Ranieri" <AndreRani***@discussions.microsoft.com> schreef in bericht
news:F9F93B29-3578-4AB1-8B0E-4DE17413773A@microsoft.com...
>I have a procedural question - in ADO.NET 1.1 when I created DataSets from
>an
> XSD schema I would create a SimpleType named "Money" and set the
> FractionDigits to 2.  Thus, my USD fields were always correctly formated
> $1.23.
>
> In ADO.NET 2.0 (at least from the IDE) I don't seem to be able to specify
> a
> simple type in my schema, or much of anything else for that matter.  What
> is
> the recommended method for locking dataset values to currency format?
>
> Thanks in advance,  I apologize but some of the changes ADO.NET 2.0 aren't
> making sense yet.
>
> Andre Ranieri
Author
6 Nov 2006 5:19 AM
Andre Ranieri
So, then, what's the solution for enforcing decimal accuracy constraints like
you'd want to see in USD currency?

Thanks in advance for any suggestions.

Andre





Show quote
"Cor Ligthert [MVP]" wrote:

> Anre,
>
> Some like it, some don't "decimal"
>
> Cor
>
> "Andre Ranieri" <AndreRani***@discussions.microsoft.com> schreef in bericht
> news:F9F93B29-3578-4AB1-8B0E-4DE17413773A@microsoft.com...
> >I have a procedural question - in ADO.NET 1.1 when I created DataSets from
> >an
> > XSD schema I would create a SimpleType named "Money" and set the
> > FractionDigits to 2.  Thus, my USD fields were always correctly formated
> > $1.23.
> >
> > In ADO.NET 2.0 (at least from the IDE) I don't seem to be able to specify
> > a
> > simple type in my schema, or much of anything else for that matter.  What
> > is
> > the recommended method for locking dataset values to currency format?
> >
> > Thanks in advance,  I apologize but some of the changes ADO.NET 2.0 aren't
> > making sense yet.
> >
> > Andre Ranieri
>
>
>
Author
6 Nov 2006 12:18 PM
Miha Markic [MVP C#]
I would do it at UI level.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"Andre Ranieri" <AndreRani***@discussions.microsoft.com> wrote in message
news:A59E9090-5DBB-4DB1-952F-036DF0085B6E@microsoft.com...
> So, then, what's the solution for enforcing decimal accuracy constraints
> like
> you'd want to see in USD currency?
>
> Thanks in advance for any suggestions.
Author
6 Nov 2006 5:18 PM
Andre Ranieri
I tried that first, however it doesn't apprear that the Windows Forms Data
Grid control lets you do that.  $0.00 is appearing in the grid cells as
$0.0000 and any calculated value is displaying an arbitrary number of decimal
places.

I can't believe the ADO.NET development team wouldn't include a way to
enforce decimal scale and precision in dataset values - - - there just has to
be a way.

Thanks,

Andre Ranieri


Show quote
"Miha Markic [MVP C#]" wrote:

> I would do it at UI level.
>
> --
Author
6 Nov 2006 6:44 PM
Earl
You can use Round to get your decimal places, Format to put it into
currency. And yes you can set your decimal scale and precision when sending
data to the database, but in this case you are mixing up display format with
database constraints.



Show quote
"Andre Ranieri" <AndreRani***@discussions.microsoft.com> wrote in message
news:3565733C-ABCA-4206-8634-5189D8B13879@microsoft.com...
>I tried that first, however it doesn't apprear that the Windows Forms Data
> Grid control lets you do that.  $0.00 is appearing in the grid cells as
> $0.0000 and any calculated value is displaying an arbitrary number of
> decimal
> places.
>
> I can't believe the ADO.NET development team wouldn't include a way to
> enforce decimal scale and precision in dataset values - - - there just has
> to
> be a way.
>
> Thanks,
>
> Andre Ranieri
>
>
> "Miha Markic [MVP C#]" wrote:
>
>> I would do it at UI level.
>>
>> --
>
Author
7 Nov 2006 10:02 PM
Andre Ranieri
So, what I'm gathering is that there's no way to enforce data constraints or
decimal precision at the middle tier (dataset) level.

The client's back-end database is MS-Access and I can't modify their
existing data schema for this reporting project, only pull data from the
database. 

Since the datagridview control doesn't seem to offer a .Format("c") option
(or something similiar)  I'm gathering that my best option is to fill the
strongly typed datatable, then iterate through every row and round the values
off before binding the table to the datagrid.   This seems like an awful lot
of processing resources thrown at a relatively common task. 

Any suggestions are always welcome.

Andre Ranieri
Author
8 Nov 2006 1:39 AM
Earl
Noooooooooo ... if you are just needing to format the datagridview, simply
set the default format for the column to currency:

dgv.Columns["Cost"].DefaultCellStyle.Format = "c";

Show quote
"Andre Ranieri" <AndreRani***@discussions.microsoft.com> wrote in message
news:C46CBBB4-D908-4259-B9AE-00D360E7B9D2@microsoft.com...
> So, what I'm gathering is that there's no way to enforce data constraints
> or
> decimal precision at the middle tier (dataset) level.
>
> The client's back-end database is MS-Access and I can't modify their
> existing data schema for this reporting project, only pull data from the
> database.
>
> Since the datagridview control doesn't seem to offer a .Format("c") option
> (or something similiar)  I'm gathering that my best option is to fill the
> strongly typed datatable, then iterate through every row and round the
> values
> off before binding the table to the datagrid.   This seems like an awful
> lot
> of processing resources thrown at a relatively common task.
>
> Any suggestions are always welcome.
>
> Andre Ranieri

AddThis Social Bookmark Button