|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can i write an object to db?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? -- Show quoteGregory A. Beamer MVP; MCP: +I, SE, SD, DBA *************************** Think Outside the Box! *************************** "basulasz" wrote: > 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? 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. Show quote "Cowboy (Gregory A. Beamer) - MVP" wrote: > 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! > *************************** > > > "basulasz" wrote: > > > 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? 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... -- Show quoteRobbe Morris - 2004-2006 Microsoft MVP C# Earn money answering .NET questions http://www.eggheadcafe.com/forums/merit.asp "basulasz" <basul***@discussions.microsoft.com> wrote in message news:586BF3F7-35B6-4079-B7B3-7F638DB7E74D@microsoft.com... >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? This is a standart outlook mail item, so a structural change is a small
possibility Show quote "Robbe Morris [C# MVP]" wrote: > 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... > > -- > Robbe Morris - 2004-2006 Microsoft MVP C# > Earn money answering .NET questions > http://www.eggheadcafe.com/forums/merit.asp > > > > > > "basulasz" <basul***@discussions.microsoft.com> wrote in message > news:586BF3F7-35B6-4079-B7B3-7F638DB7E74D@microsoft.com... > >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? > > > I wouldn't bet on that...
-- Show quoteRobbe Morris - 2004-2006 Microsoft MVP C# Earn money answering .NET questions http://www.eggheadcafe.com/forums/merit.asp "basulasz" <basul***@discussions.microsoft.com> wrote in message news:85D6C162-8E92-4492-8F98-F8D83DA3C5C8@microsoft.com... > This is a standart outlook mail item, so a structural change is a small > possibility > > "Robbe Morris [C# MVP]" wrote: > >> 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... >> >> -- >> Robbe Morris - 2004-2006 Microsoft MVP C# >> Earn money answering .NET questions >> http://www.eggheadcafe.com/forums/merit.asp >> >> >> >> >> >> "basulasz" <basul***@discussions.microsoft.com> wrote in message >> news:586BF3F7-35B6-4079-B7B3-7F638DB7E74D@microsoft.com... >> >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? >> >> >> :) 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.... Show quote "Robbe Morris [C# MVP]" wrote: > I wouldn't bet on that... > > -- > Robbe Morris - 2004-2006 Microsoft MVP C# > Earn money answering .NET questions > http://www.eggheadcafe.com/forums/merit.asp > > > > > > "basulasz" <basul***@discussions.microsoft.com> wrote in message > news:85D6C162-8E92-4492-8F98-F8D83DA3C5C8@microsoft.com... > > This is a standart outlook mail item, so a structural change is a small > > possibility > > > > "Robbe Morris [C# MVP]" wrote: > > > >> 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... > >> > >> -- > >> Robbe Morris - 2004-2006 Microsoft MVP C# > >> Earn money answering .NET questions > >> http://www.eggheadcafe.com/forums/merit.asp > >> > >> > >> > >> > >> > >> "basulasz" <basul***@discussions.microsoft.com> wrote in message > >> news:586BF3F7-35B6-4079-B7B3-7F638DB7E74D@microsoft.com... > >> >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? > >> > >> > >> > > > You have been better off writing your own class that mirrors
mail item. At least if Outlook changes, it won't blow up your app. -- Show quoteRobbe Morris - 2004-2006 Microsoft MVP C# Earn money answering .NET questions http://www.eggheadcafe.com/forums/merit.asp "basulasz" <basul***@discussions.microsoft.com> wrote in message news:9AC91ADA-9F81-4B08-9A37-D28E345250F7@microsoft.com... > :) > 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.... > > "Robbe Morris [C# MVP]" wrote: > >> I wouldn't bet on that... >> >> -- >> Robbe Morris - 2004-2006 Microsoft MVP C# >> Earn money answering .NET questions >> http://www.eggheadcafe.com/forums/merit.asp >> >> >> >> >> >> "basulasz" <basul***@discussions.microsoft.com> wrote in message >> news:85D6C162-8E92-4492-8F98-F8D83DA3C5C8@microsoft.com... >> > This is a standart outlook mail item, so a structural change is a small >> > possibility >> > >> > "Robbe Morris [C# MVP]" wrote: >> > >> >> 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... >> >> >> >> -- >> >> Robbe Morris - 2004-2006 Microsoft MVP C# >> >> Earn money answering .NET questions >> >> http://www.eggheadcafe.com/forums/merit.asp >> >> >> >> >> >> >> >> >> >> >> >> "basulasz" <basul***@discussions.microsoft.com> wrote in message >> >> news:586BF3F7-35B6-4079-B7B3-7F638DB7E74D@microsoft.com... >> >> >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? >> >> >> >> >> >> >> >> >> |
|||||||||||||||||||||||