473,800 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Formatting TextBox Data

63 New Member
Hi,

I have a multiline TextBox. Text contained in the TextBox will be stored in a SQL Server Database.
How do I format the textBox correctly for database entry?
e.g. How do I ensure that new lines will be added, etc?

Thanks.
May 15 '07 #1
18 2509
kenobewan
4,871 Recognized Expert Specialist
Please explain your problem and platform clearly. Thanks.
May 15 '07 #2
Plater
7,872 Recognized Expert Expert
Aside from watching out for single quotes, you should be fine?
(replace each instance of a single quote with two single quotes)
May 15 '07 #3
TRScheel
638 Recognized Expert Contributor
Aside from watching out for single quotes, you should be fine?
(replace each instance of a single quote with two single quotes)
And watch for sql injections
May 15 '07 #4
Frinavale
9,735 Recognized Expert Moderator Expert
Hi,

I have a multiline TextBox. Text contained in the TextBox will be stored in a SQL Server Database.
How do I format the textBox correctly for database entry?
e.g. How do I ensure that new lines will be added, etc?

Thanks.
You have to screen the text in the TextBox.
You'll have to grab it and filter it to make sure that it is formatted the way that your database expects (eg. is less than the max length). It is also Strongly advised that you screen for malicious database commands that may be executed while running database queries at later dates. You should look for "Drop Table", "Delete", "Select", "Truncate"..... .
May 15 '07 #5
obrienkev
63 New Member
sorry, the database data is actually displayed in a dataGridView

tried this...
Expand|Select|Wrap|Line Numbers
  1. Eval(queryTextDataGridViewTextBoxColumn).ToString().Replace(System.Environment .NewLine, "<br />"); 
  2.  
But VS2005 gives this error...
Expand|Select|Wrap|Line Numbers
  1. The name 'Eval' does not exist in the current context 
  2.  
May 17 '07 #6
Plater
7,872 Recognized Expert Expert
Eval is not a function in C#, it might be in VB, what language are you using?
May 17 '07 #7
Frinavale
9,735 Recognized Expert Moderator Expert
Eval is not a function in C#, it might be in VB, what language are you using?
I've never seen it in VB either.
Maybe its a custom function?
May 17 '07 #8
Plater
7,872 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. Eval(queryTextDataGridViewTextBoxColumn).ToString().Replace(System.Environment .NewLine, "<br />"); 
  2.  
Best I can tell Eval() is used in other languages to take a string and do operations on it, like Eval("1+2") would give you 3. Not sure what he is attempting to do there with it?

If you want the text from a field, get to the correct Cell (DataGridViewCe ll) and use it's .Value property. So like
Expand|Select|Wrap|Line Numbers
  1. string celltextwithbr=mycell.Value.ToString().Replace(System.Environment .NewLine, "<br />"); 
  2.  
May 17 '07 #9
Frinavale
9,735 Recognized Expert Moderator Expert
Best I can tell Eval() is used in other languages to take a string and do operations on it, like Eval("1+2") would give you 3. Not sure what he is attempting to do there with it?

If you want the text from a field, get to the correct Cell (DataGridViewCe ll) and use it's .Value property. So like
Expand|Select|Wrap|Line Numbers
  1. string celltextwithbr=mycell.Value.ToString().Replace(System.Environment .NewLine, "<br />"); 
  2.  

Yeah JavaScript has an Eval() function that does precisely that.
May 17 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1480
by: Kyle | last post by:
Is there an easy way to format data in a textbox control? I have a textbox control bound to a dataset and I would like the datetime data to be formatted as "MM/dd/yyyy" instead of the standard display format. Thanks.
2
5838
by: Neil | last post by:
Is there an editable RTF textbox control which allows the user to apply bold, italic, etc.? I tried the Microsoft Rich Textbox Control, but there doesn't seem to be a way to allow the user to change the formatting while typing text. Is there such a beast? Thanks, Neil
7
3943
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34 123.0000 123 i.e. I want to trim trailing zeros and (decimal point if no decimal values
0
1315
by: d pak | last post by:
Here is a snippit which replicates my issue. I have a datagrid which contains an input textbox on each row, binded on the serverside. However it seems that when I perform a postback to refresh teh numbers, they are not changing due to the foreach loop I have in this code. When I comment out the foreach loop, the numbers refresh fine (but the text boxs ovbiously no longer get created). I have placed this code in the OnItemDataBind method,...
4
2932
by: Peter Newman | last post by:
the data input app im writing has some 30 + input fields and i want to be able to format them. I know i can use the .validate on each textbox and format the 'string' however this require loads of repetitive codeing. Is there a way possible to globally format the textboxes both on the .validate function, as well as when the enter key is pressed. Any suggestions or examples wouldbe very usefull, as i have a loads of these data forms...
7
16479
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so they can only input numerical values. Is there any way to do this? Currently my formatting works but if the user enters a value manually the formatting is not applied to the new value. Also I haven't found a way to allow only numerical input....
5
13533
montzter
by: montzter | last post by:
Hi evryone, I'm having trouble in formatting the inputed data in the text box so that everytime user lost focus it will adjust its value to contain the format (#,####.##). ie user will input 1111.1 it will immediately be converted to 1,111.10 as its value. I've tried using this code in every lost focus: textbox.text = round(val(textbox.text)), 2) but the problem with this is I am not getting the comma and if the user enters an exact...
8
6557
by: Mihai N. | last post by:
I need to format any decimal value so that it is right aligned, thousands It is good to show the info in the format the user prefers. That is language/locale speciffic (CultureInfo in the .NET lingo) So you should use something like ToString("N") If you are sure you want 2 digits after decimal separator, then use "N2" --
6
4608
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this works fine: Text='<%# Eval("Price", ApplicationContext.CurrencyFormat) %>'
12
4849
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I want to plant an Easter Egg in our software. We have a TextBox that is multiline and used to display all sorts of messages on the screen for our operators based on database queries and such. The Easter Egg I want to create would send a dump of the data for a particular part number to the screen when a certain secret combination of characters is pressed. If it works out well, I can actually impliment it on our production floor.
0
9694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10509
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10256
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10039
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9095
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.