Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Data Type for System.Drawing.Color

Tags:

c#

.net

sql

I want to save a setting in MS SQL for .net Color. What data type in MS SQL should I use?

like image 598
spinner_den_g Avatar asked Feb 17 '12 23:02

spinner_den_g


People also ask

Which datatypes allows symbols in SQL?

VARCHAR (length) The VARCHAR data type accepts character strings, including Unicode, of a variable length is up to the maximum length specified in the data type declaration.

What is float type in SQL?

Float Data Type Float is an approximate number data type used to store a floating-point number. float (n) - n is the number of bits that are used to store the mantissa in scientific notation. Range of values: - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308.

Does SQL have float data type?

The SQL Server float[(n)] data type complies with the ISO standard for all values of n from 1 through 53. The synonym for double precision is float(53).


2 Answers

Use Int32, then use Color.FromArgb(Int32) and Color.ToArgb() to read and write, respectively. See: http://msdn.microsoft.com/en-us/library/ed705s37.aspx

like image 75
Diego Avatar answered Oct 21 '22 12:10

Diego


The easy way would be to use color.ToArgb() to convert it to a 32-bit integer and store it as that. You can convert it back to a color using the static method Color.FromArgb(int).

like image 44
Joachim Isaksson Avatar answered Oct 21 '22 12:10

Joachim Isaksson