Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to save some rich text into my sql server database, and my solution is serializing the string of rtf (achieved from RichTextBox.Rtf) into a stream, then converting this stream into an array of bytes (byte[]), and lastly, save these bytes into a field of binary (or image) of a Sql server table. This solution can store the richtext well but I don't know how to search the saved data for some keyword, could you tell me how to do that?
If possible, could you help me achieve both of the two purposes: 1. Save richtext.
2. Search the saved richtext.
Your help would be highly appreciated!
Posted

1 solution

Quickly comes in mind that why not store the rtf in binary field and the text portion of the rtf in a separate field that would be searchable using normal SQL functions.
 
Share this answer
 
Comments
supernorb 23-Dec-11 22:48pm    
That would work greatly. But do you think the database size will double the normal size?
Or that is the expense we have to accept? Don't we have any other ways?
If not, I would use that way and thank you for the great solution.
Wendelius 24-Dec-11 3:06am    
The size will certainly grow. I don't think it's going to double since formatting are not stored twice.

Depending on the situation perhaps another solution could be to store the text portion inside the database and the rtf files using filestream. Have a look at: How to store and fetch binary data into a file stream column[^]
supernorb 24-Dec-11 15:42pm    
Thank you so much!
I have just known of a new tech from you.
Wendelius 24-Dec-11 16:45pm    
You're welcome, glad it helped :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900