none
How To save RTF file in SQl Server RRS feed

  • Question

  • hello every body

    in my last project i have  problem that i want to save the content of RTF file in my database (sql server 2005) , i must keep the font formation (Bold, Italic, Underline , .. etc ) in the data which will be stored in database

     

    when i  search in this subject i found that i must define the filed of type "image"

    but how i can save and retrive  the data  ?

    can any one help  ??!!!

    Tuesday, November 6, 2007 6:44 PM

Answers

  • Hi,

     

    I haven't tested it but something like this should work:

     

    MemoryStream stream = new MemoryStream();

    richTextBox.Save(stream);

    byte[] data = stream.GetBuffer();

     

    sqlCommand.Parameters["@RtfDocument"].Value = data;
    sqlCommand.ExecuteNonQuery();
    Hope this helps,
    Charles
    Wednesday, November 7, 2007 2:56 AM

All replies

  • Hi,

     

    I haven't tested it but something like this should work:

     

    MemoryStream stream = new MemoryStream();

    richTextBox.Save(stream);

    byte[] data = stream.GetBuffer();

     

    sqlCommand.Parameters["@RtfDocument"].Value = data;
    sqlCommand.ExecuteNonQuery();
    Hope this helps,
    Charles
    Wednesday, November 7, 2007 2:56 AM
  • thank you very much Charles

    i will try it and tell you  the result 

    Wednesday, November 7, 2007 5:52 PM