Solved

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
7
830 Views
Last Modified: 2008-01-09

Hi

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

Matthew
0
Comment
Question by:mj_stanton
  • 4
  • 3
7 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
ID: 17109236
0
 

Author Comment

by:mj_stanton
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"))
0
 
LVL 34

Expert Comment

by:Sancler
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.

Roger
0
Industry Leaders: 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!

 

Author Comment

by:mj_stanton
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 .

Thanks

Matthew
0
 

Author Comment

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

Author Comment

by:mj_stanton
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.

Regards

Matthew
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17110847
Matthew

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 ;-)

Roger
0

Featured Post

Industry Leaders: 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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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