Solved

RichTextBox Control  population

Posted on 2014-03-24
3
289 Views
Last Modified: 2014-03-25
How do you place a null  into a RichTextBox control?
0
Comment
Question by:metro156
  • 2
3 Comments
 
LVL 40
ID: 39952235
Define what you see as a null. A database null or a code null? A null character or a completely empty RichTextBox? And what language are you using, VB or C#?

If you mean to empty the RTB, then the following should do it:

RichTextBox1.Text = Nothing ' VB
RichTextBox1.Text = null; // C#

But depending on the use, since Text is a string, and since a string can both be empty and have a value of String.Empty, it might not be considered as null, depending on how you use it.

Please, give more information about what you mean by "a  null  into a RichTextBox control", as well as how you intend to use this value, and we should be able to give you a more precise answer.
0
 

Author Comment

by:metro156
ID: 39952855
I need to put a null value into a column of a sql server database table via the RichTextBox.


Using C#.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39953166
How do you send your update to the server?

To send a null value to the server, you need to use DBNull.Value, which cannot be stored in a RichTextBox because it cannot be converted to a String.

Thus the null cannot come directly from the control. You will have to detect the fact that the control is empty and send a DBNull.Value instead to the database.

An alternative is not to accept null in the database, and consider an empty string as your null value for that field.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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