Home All Groups Group Topic Archive Search About

saving object properties in sqlserver

Author
1 Apr 2007 9:38 PM
Jeff User
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

Author
2 Apr 2007 4:29 PM
Göran_Andersson
Jeff User wrote:
Show quote
> 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

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;

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

AddThis Social Bookmark Button