How can i write an object to db?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I get an e-mail in C# I want to store this e-mail item in SQL Server 2005. I
don't have any hardcopy of this mail item. I only have a programmatic C#
object, and i wish to insert it into a varbinary field. How can i convert
this object to a suitable form to insert to db?
 
One option: if serializable, serialize and save the XML in the database (not
as useful for querying, but good archive - in SQL 2005, you can query it as
an XML type).

You could potentially save as a binary, but you would have to write the
engine to save and reconstitute. It would also be proprietary.

Another option is to feed the object to an "engine" that pulls the values
and saves them to a database.

Which option you choose depends on your needs. Is this simple archive or are
you going to mine the info later?


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
What happens if you change the structure of your class
6 months from now?

When you go to deserialize your stored class into
the format of the new class, you are going to have issues.

You still need to do it the old fashioned way...
 
This is an Outlook 2003 e-mail object which is created by Outlook Mailitem.
For some security and portability reasons my directors want these mails to be
stored in db, and reusable when they wish.
 
:)
I got the solution. Outlook 2003 mail item is not serializable. I have
created a new mail item class implementing ISerializable and
Outlook.MailItem. And serialized it, so i am able to serialize it and insert
into db.

Thanks for comments and brain storming....
 
Back
Top