|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Save a System.Drawing.Color in the dbHi,
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! 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 -- Show quoteHide quoteChris 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! > > > 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 . Show quoteHide quote "Chris Holland" <ChrisHoll***@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! > > > > > >
Other interesting topics
A challenge to all MVP's.......GET A J.O.B. for once in your life
How to do simple memcpy in C#? Text Files, Encoding and NewLine character Read File Fast Self populating collection Simple architecture question. Enable a windows form over another one? Implementing an interface by relying on base class Send mail in BOTH html and text formats MSCORCFG |
|||||||||||||||||||||||