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
824 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now