Insert rich text box into database

J

Jim P.

I have a rich text box that I want to 'insert' into my SQL2K db. But I'm
not sure how to handle it. Do I convert it to XML first? Do I place the
rich text box in an object then insert it as a binary object?

thanks.
 
R

Robert Jacobson

Do you need to save the rich text box itself, or just the _contents_ of the
box? (I.e., the formatted text.)

Assuming you just want to persist the contents of the box, simply retrieve
the .Rtf property from the richtextbox. It returns a string that contains
the text of the contents, along with embedded formatting codes. (It's
similar to HTML.) Save that string into the database. To restore the box,
do the opposite -- retrieve the string and assign it to the box's .Rtf
property.

If you need to persist the entire box -- its dimensions, contents, etc. --
you could possibly serialize the box to a string that you can then save in
your database, and then later deserialize that string into a box later on.
That's a good deal more complicated though, and hopefully unnecessary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top