I have a winform richtextbox which save the rtf to SQL database nvarchar(4000) field which a [Save] button is pressed. Now, the user want to add a picture to the richtext content, the problem is that the picture cannot be saved together with rft to the nvarchar field. How can I save rtf with the picture to a binary field instead of nvarchar fields
Thanks in advance.

Save richtextbox graphic to link
Aaron Klotz
hang on, what am I thinking!
ignore all that
basically you get the .Rtf property, which contains the RTF code for the richtextbox control current text in there - so take that and insert it into SQL, of course, adjust the data length to fit the data correctly
problem you are still going to have is the data length, since nvarchar can be a max of 4000, the images will take much much more than that in the RTF text length. You may be better perhaps as suggested, to get the bytes[] of the file and insert that into SQL then fetch it whenever you need to.
Jon Choy
I believe you may need to change the data type of that field in SQL to binary, then convert the rtf text/input to binary before insertion. (get the bytes). Then to read it and put it back in, convert it back to string.
Thing is, you need to know the length of data for that field in SQL. I have been able to do it but thats because I Was doing a simple test and knew how much data to give one entry. If you are interested, I can post the code I used for inserting this, and reading back, from SQL I'm sure there is a better way.
One other way would be to get the bytes[] of the File used to load into the RTB control, and store that into SQL, then when reading, get the bytes[] and write to file or memorystream, then load it into the RTB control. I think this may not be a bad idea but could be wrong
Fusion1224
Thanks a lot ahmedilyas! You answer is right! Someone executed at
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=667916&SiteID=1