Wednesday, March 21, 2012

Saving a custom object in a sql database table.

Hi,
Using VB.net I have created a custom object (hope my terminology is correct here), it's just a class that defines a few string, integer, and hash table variables. After creating an instance of this class and populating it with data I need to be able to store this instance of my object in a sql server data base table. How do I do this? I saw an article that used the image data type to achieve this (code was in java unfortunately) is this the correct approach. Could you please give me some code examples

Thanks

If you give your class the Serializable attribute, you can bsaically save it to, and load it from a stream, (or string). This means it can be easily saved to a file, database, or even copied across the internet without fear of it being blocked. You can also save it as binary too.

Since you are in effect creating an XML data string when you serialize, you can either save it in an SQL Server 2005 xml field, or into a text field in SQL Server 2000

Have a look athttp://msdn2.microsoft.com/en-us/library/et91as27.aspx

No comments:

Post a Comment