Saving headers and footers. Saving images

  • Hi,

    I am saving the contents of my TextDynamic control into a SQL database. I can save the body of the text by code like

    Code
    MyTableAdapter.Insert( Me.WpdllInt1.Memo.SaveToString(True, "AUTO"))

    I can load it with code like

    Code
    Me.WpdllInt1.Memo.LoadFromString(MyDataInRTF, False, "AUTO")


    However this does not save footer and header information as it does when saving to a file.

    Currently my database field is of memo or varchar type. Is there a way of saving header and footer information in one field or even in a number of fields in the database. Also curious to see if images can be saved in the database along with text.

    Thanks again,

    Geoff

    • Offizieller Beitrag

    Hi,

    it seems so you are only saving the selected text.
    ( http://www.wpcubed.com/manuals/word_p…aveToString.htm )

    Please use SaveToString(false, "RTF")

    to load use

    LoadFromString( data, false, "AUTO" )

    For a databases it is better to use a stream for data transfer - .NET strings are always double byte but RTF code is based on single byte ASCII code. So the conversion forth and back is useless and only costs performance and memory.

    If you haven't found that already here is the Load&Save category in the reference:
    http://www.wpcubed.com/manuals/word_p…/idh_cat_io.htm

    Thanks for the imrovement to the example from your other post (and also for your compliment :-). If you have a little demo project (zip file) you don't mind to post here please let me know and I put it on this server.

    Kind Regards,

    Julian Ziersch

  • Thanks. Works like a charm. See new post re example download.

    Not quite sure how to use a stream for data transfer. Would I still use a memo field to store data in database? Any example would be nice but at you leisure.

    Regards,

    Geoff

    • Offizieller Beitrag

    Hi,

    Zitat

    Not quite sure how to use a stream for data transfer. Would I still use a memo field to store data in database? Any example would be nice but at you leisure.

    I do not have a ready to use example since that all depends so much on your installed database.

    But - in general you can work with a stream like this:

    Code
    IWPMemo Memo = WPDLLInt1.Memo;
    FileStream textstream = new FileStream(@"C:\SomeText1.htm",FileMode.Open);
    Memo.LoadFromStream(new WPDynamic.Stream2WPStream(textstream),false, "" );
    textstream.Close();

    I found C# example code which works with database blobs and streams here - http://support.microsoft.com/kb/317017/
    But I think it will be much easier if next release of the TextDynamic assembly would operate with Byte[] arrays for load&save. This way the OleDbDataReader.GetBytes method could be directly used, without having to create an intermediate stream.

    Regards,

    Julian