Hi,
I have a DataTable that has a Color type DataColumn. I use
OleDbDataAdapter.Update(myTable) to update the db. Is there a place(an
event?) where i can do a type conversion from Color to string (or int) so
that the value can be saved in the db? What is the preferred way of
saving/reading Color DataColumns in the db? The point is the call to
OleDbDataAdapter.Update(myTable) appears to be atomic an offers no event to
do such a conversion. Therefore, you end up with a string column in the db,
and an incompatible Color DataColumn in your DataTable ! I'm caught with
this.

Thanks for any help!

RE: Save a System.Drawing.Color in the db by ChrisHolland

ChrisHolland
Mon Jun 06 13:56:02 CDT 2005

Hi Richard,

You can convert from a Color to an Int32 using Color.ToArgb() and store the
int value in the database. To retrive the Color use FromArgb(int32) to
convert from the int back to a Color

--
Chris Holland


"Richard Brunet" wrote:

> Hi,
> I have a DataTable that has a Color type DataColumn. I use
> OleDbDataAdapter.Update(myTable) to update the db. Is there a place(an
> event?) where i can do a type conversion from Color to string (or int) so
> that the value can be saved in the db? What is the preferred way of
> saving/reading Color DataColumns in the db? The point is the call to
> OleDbDataAdapter.Update(myTable) appears to be atomic an offers no event to
> do such a conversion. Therefore, you end up with a string column in the db,
> and an incompatible Color DataColumn in your DataTable ! I'm caught with
> this.
>
> Thanks for any help!
>
>
>

Re: Save a System.Drawing.Color in the db by Richard

Richard
Mon Jun 06 15:59:44 CDT 2005

I know Chris, the thing is WHEN can i do this? I recall that i use
OleDbDataAdapter.Update(myTable) where myTable schema has a Color column,
and the database has a corresponding string column (could change for an int
too depending on the solution). I want to avoid doing the conversion on the
client side (within the form code) using Binding.Parse and Format ... I'm
looking for a server-side solution so the server can send to the client a
DataTable containing a System.Drawing.Color column, not an Int32 column
(which would be more natural for the client side...).

Thanks .

"Chris Holland" <ChrisHolland@discussions.microsoft.com> a écrit dans le
message de news:1A4413F5-D6A3-4D0E-91F8-9C5DA58D9A4D@microsoft.com...
> Hi Richard,
>
> You can convert from a Color to an Int32 using Color.ToArgb() and store
the
> int value in the database. To retrive the Color use FromArgb(int32) to
> convert from the int back to a Color
>
> --
> Chris Holland
>
>
> "Richard Brunet" wrote:
>
> > Hi,
> > I have a DataTable that has a Color type DataColumn. I use
> > OleDbDataAdapter.Update(myTable) to update the db. Is there a place(an
> > event?) where i can do a type conversion from Color to string (or int)
so
> > that the value can be saved in the db? What is the preferred way of
> > saving/reading Color DataColumns in the db? The point is the call to
> > OleDbDataAdapter.Update(myTable) appears to be atomic an offers no event
to
> > do such a conversion. Therefore, you end up with a string column in the
db,
> > and an incompatible Color DataColumn in your DataTable ! I'm caught with
> > this.
> >
> > Thanks for any help!
> >
> >
> >