saving object properties in sqlserver

J

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Jeff said:
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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top