Results 1 to 18 of 18

Thread: Storing Rich Text in a database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Location
    Melbourne
    Posts
    20

    Storing Rich Text in a database

    I want to store extracts from a web page or HTML-formatted email into my userform control (Rich Text Box) and then store the data into an Access database keeping the formatting. I've used a Memo field in the database.

    Is this the correct way to do it?
    |
    +--Thief_
    |
    +--VB6
    +--VB Dot Net
    |

  2. #2

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Storing Rich Text in a database

    You could use a memo field if you save the RTF formatted string to it. To get the RTF string from a RichTextBox use the TextRTF property instead of the regular Text property.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Location
    Melbourne
    Posts
    20

    Re: Storing Rich Text in a database

    Quote Originally Posted by RhinoBull
    Memo field wouldn't save any formating at all. What you need is OLE object type field so you can save entire file but you will need to create rtf file first.
    Search forum for saving files in database.
    Had a look but couldn't find much on how to save the RTB dat to an RTF file then load it into Access. Have u got a link to sample code which could help me?

    JA. Thanks for that. I'll give that a go too.
    |
    +--Thief_
    |
    +--VB6
    +--VB Dot Net
    |

  5. #5
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Storing Rich Text in a database

    You could use a memo field if you save the RTF formatted string to it. To get the RTF string from a RichTextBox use the TextRTF property instead of the regular Text property.
    Just do....

    VB Code:
    1. RS!Blob = RichTextBoxReference.TextRTF

    The blob holds the complete rich text box text plus formatting.

    .
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Location
    Melbourne
    Posts
    20

    Re: Storing Rich Text in a database

    Quote Originally Posted by David.Poundall
    Just do....

    VB Code:
    1. RS!Blob = RichTextBoxReference.TextRTF

    The blob holds the complete rich text box text plus formatting.
    Thnx David. What's a "blob"? How is it setup in an Access table?
    |
    +--Thief_
    |
    +--VB6
    +--VB Dot Net
    |

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Storing Rich Text in a database

    The binary field that holds files or images, or in your case, Richtext.
    Substitute your fieldname, which you declare as a BLOB type.

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Storing Rich Text in a database

    Actually, you don't need to use a Blob (and shouldn't in this case). Since the RTF text is nothing but a text you can use a memo field.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Location
    Melbourne
    Posts
    20

    Re: Storing Rich Text in a database

    So do you think I can paste parts of a web page into a RTB exactly as it's displayed in MSIE and then have that saved to a memo field to be later displayed in all its original glory??
    |
    +--Thief_
    |
    +--VB6
    +--VB Dot Net
    |

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Storing Rich Text in a database

    I think so, I have looked at RTF of my page, and it is viewable in Wordpad. In notepad, it is just text, except the inline image, which is binary.

  11. #11
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Storing Rich Text in a database

    Quote Originally Posted by Joacim Andersson
    Actually, you don't need to use a Blob (and shouldn't in this case). Since the RTF text is nothing but a text you can use a memo field.
    Sorry - I name the fields as Blobs but you are quite correct - specifically the record is stored in a memo field. Apologies if it misled you Thief

    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  12. #12
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Storing Rich Text in a database

    Quote Originally Posted by Thief_
    So do you think I can paste parts of a web page into a RTB exactly as it's displayed in MSIE and then have that saved to a memo field to be later displayed in all its original glory??
    If it is viewable in the RTB then you can save it. If you have images in there it may start to take up a lot of space in your databse though.
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Location
    Melbourne
    Posts
    20

    Re: Storing Rich Text in a database

    I've just checked how an RTB works with web page data, and it works, but it sucks more than anything when it comes to formatting.

    I suppose what I need is some sort of web control which accepts the copy-paste off a web page, stores the info as HTML and when displayed, acts sorta like a web browser control.

    Is there such a thing and if so, is there some sample code to show how it works?
    |
    +--Thief_
    |
    +--VB6
    +--VB Dot Net
    |

  14. #14
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: Storing Rich Text in a database

    No - afraid not. What's the background to what you are trying to do. Is it a project need or wishfull thinking?
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Location
    Melbourne
    Posts
    20

    Unhappy Re: Storing Rich Text in a database

    Thanks David.

    I'm the admin for a Message Handling System for the company. One of my roles is to develop a Knowledge Base of the errors we receive from the MHS system and document the fix.

    The errors are presented to me via a web browser.

    My aim is to copy a part of the web browser screen to the KB app then type in the resolution so that others can see how to fix the same problem in the future when new versions are distributed and similar problems arise.
    |
    +--Thief_
    |
    +--VB6
    +--VB Dot Net
    |

  16. #16
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Storing Rich Text in a database

    maybe convert it to xml? except that it would strip out the formatting.

  17. #17
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Storing Rich Text in a database

    Quote Originally Posted by RhinoBull
    Memo field wouldn't save any formating at all. What you need is OLE object type field so you can save entire file but you will need to create rtf file first.
    Search forum for saving files in database.
    As I said: best bet is to save entire file ...
    Take a look at this sample - it stores image file but logic would be the same:

    http://www.vb-helper.com/howto_database_picture.html

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Location
    Melbourne
    Posts
    20

    Re: Storing Rich Text in a database

    Thanks Rhino,

    How would I get the web-based data onto a control on a userform? What control will accept pasted (formatted) data?
    |
    +--Thief_
    |
    +--VB6
    +--VB Dot Net
    |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width