Hi
Using vs2003 and sql server 2000
I would like ot save asp.net object attrributes such as alignment for
a table cell, in sql server database.
In my C# code I ahve to declare this as a HorizontalAlign type. then I
give my variable the value "HorizontalAlign.Center". Now I can set the
cell Horizontal align property to this variable.
Is there way to save these special "types" in sql server, since I
could not just appply the word "left" (for example) to the table cell
Horizontal align attribute.
Thanks
jeff
Göran Andersson - 02 Apr 2007 17:29 GMT
> Hi
> Using vs2003 and sql server 2000
[quoted text clipped - 11 lines]
> Thanks
> jeff
You can cast the enum value to an int, and save in the database. When
you read the int from the database, you can cast it back to the enum value.
Example of casting:
// you have an enum value:
HorizontalAlign align = HorizontalAlign.Center;
// cast it to an integer:
int alignValue = (int)align;
// cast it back to the enum value:
HorizontalAlign align2 = (HorizontalAlign)alignValue;

Signature
Göran Andersson
_____
http://www.guffa.com