How do I Databind a Rich Text Box Control with MS SQL Server ntext field so it does not loose its rich text changes?

Posted on 2006-07-14
Last Modified: 2008-01-09


I have a simple Winforms application built in VB.Net 2003 were I am using a Rich Text Box Control to bind to a field on a MS SQL Server 2000 (ntext field called "Content" .

I have built the Command buttons to bold specific text sections and so on but when I save the data and reload it again changes to the content are made but the formating changes are not saved.

The binding code I am using is as follows;

RichTextBox_Content.DataBindings.Add(New System.Windows.Forms.Binding("Text", SQL_QuickDocEDIT_DataSet, "MSSP_QuickDoc_EDIT_SelectCommand.Content"))

Should I be using something else instead of "Text"? or Should I be binding to a different SQL datatype? or doing something else?

Thanks in Advance

Kind Regards

Question by:mj_stanton
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 34

Accepted Solution

Sancler earned 500 total points
ID: 17109236

Author Comment

ID: 17109560
I tried changing the "Text" property to "rtf" instread of "text" (as follows) but it was not sucessful ;

TextBox_Regarding_Subject.DataBindings.Add(New System.Windows.Forms.Binding("rtf", SQL_QuickDocEDIT_DataSet, "MSSP_QuickDoc_EDIT_SelectCommand.Regarding-Subject"))
LVL 34

Expert Comment

ID: 17110144
In what way was it not successful?  

I'm not an adept at MS SQL but, from what I do know, ntext should be the right sort of datatype.  It looks - from such documentation as I have - to be as virtually "open-ended" as an Access memo field.

Was nothing passed to the database?  Did what was passed to the database not display with formatting when it was returned?   If you look at the relevant field in the database/datatable through some sort of text reader (e.g. message box, or debug.writeline) did it have any rtf formatting code in it?

Given that rtf is just string data - all its formatting is done by embedded strings - there is no reason why it shouldn't save to any database.  But without knowing more about where the link between what was in the textbox and what later got back to the textbox was broken, it's very difficult to start guessing how to put it right.

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 17110443
Sorry Roger

I should have provided more information. Appartently from some follow up research I did MS made the Rtf property unavailable as standard in the property editor in Visual Studio 2003.

When I use the original binding statement the data loads I can edit the text and save the changes and it comes  back when I reload the data from the database but any RTF changes I make such as bold is lost when I send the SQLUpdatecommand .



Author Comment

ID: 17110539
When I use "Rtf" instead for "TEXT" in the Databinding I get a error Data Access Application block saying "Invalid file format".

Author Comment

ID: 17110742
I figured it out "Rtf" is correct, the problem was that I was not creating a new record each time. This means I was loading data created in plain text and from when I was using "Text" in the databinding statement.

When I created a new record using "RTF" property in the Databinding statement it worked fine.

Roger thanks your first reply did lead to the correct solution it was the implementation that was the problem.


LVL 34

Expert Comment

ID: 17110847

Thanks for letting me know, and for the points.  I was just pondering how to guide you step by step through a debugging process.  But that won'te be necessary now ;-)


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question