Storing objects in SQL Server table

  • Thread starter Thread starter Diego F.
  • Start date Start date
D

Diego F.

Hello. I need to store custom objects in a SQL Server 2000 table. Which is
the easiest way to do it? Do I need to write methods to store each attribute
separately from C# app to the table and the opposite as well?

Regards,

Diego F.
 
Diego said:
Hello. I need to store custom objects in a SQL Server 2000 table. Which is
the easiest way to do it? Do I need to write methods to store each attribute
separately from C# app to the table and the opposite as well?

Use binary formatter to serialize the object to a memory stream. Then store
the byte array in teh memory stream in an Image field in sqlserver. To read
an object back, first create a memory stream from the Image field's data,
then deserialize the data using the binary formatter. :)

Frans.
 
The problem I see with binary serialization is that I need later to manage
the fields in the table. Is a better idea for my application to write a
method that maps attributes to fields?
I don't need to build objets back again, just storing them in the database.

Regards,

Diego F.
 
Back
Top