473,486 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

RichTextBox - the correct choice and how to loop

Hello,

I'm working on a pretty simple web app in which the user will be
pasting in a list of values (letters and number - like "1V456") most
likely from an Excel worksheet. I then want the application to check
this list against tables in a sql server database for different things
(like - does it exist in database, etc.) My co-worker thinks that a
richtextbox is the best control to use for this. I'm new to VB.Net so
I'm not real familiar with this control. Is it the right way to go?
I've been doing a little research on the web and don't see it used too
much for this situation. I have been playing with it a bit and have
gotten results to point to a table, but it is adding in strange
characters and blank entires. Here is the code:

<code>
For Each str As String In RichTextBox1.Lines
InsertSQL = "Insert into Test_test values ('" & str & "
')"
dr1 = SqlHelper.ExecuteReader(CONNSTRING,
CommandType.Text, InsertSQL)
Next

</code>

Is a "For each" statement the way to go?

Thanks in advance for your time!

JCC
Dec 14 '07 #1
2 1492

"JCCDevel" <JC******@gmail.comwrote in message
news:69**********************************@d21g2000 prf.googlegroups.com...
Hello,

I'm working on a pretty simple web app in which the user will be
pasting in a list of values (letters and number - like "1V456") most
likely from an Excel worksheet. I then want the application to check
this list against tables in a sql server database for different things
(like - does it exist in database, etc.) My co-worker thinks that a
richtextbox is the best control to use for this. I'm new to VB.Net so
I'm not real familiar with this control. Is it the right way to go?
I've been doing a little research on the web and don't see it used too
much for this situation. I have been playing with it a bit and have
gotten results to point to a table, but it is adding in strange
characters and blank entires. Here is the code:

<code>
For Each str As String In RichTextBox1.Lines
InsertSQL = "Insert into Test_test values ('" & str & "
')"
dr1 = SqlHelper.ExecuteReader(CONNSTRING,
CommandType.Text, InsertSQL)
Next

</code>

Is a "For each" statement the way to go?

Thanks in advance for your time!

I don't see any problems in what you're doing. Does it work for you? That's
all that counts is that it works for you. There several ways that one could
possibly do things, but just use the one you are using.

I would stick with what you got.

However, you need to do a SqlBless function on the str SqlBless(str) on that
Insert statement, because special characters can be in that str that can
make the Insert terminate, if they are not accounted for on the Insert.

You can use Google to lookup SqlBless and apply the function in your
program.

>
JCC
Dec 14 '07 #2

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:u3****************@TK2MSFTNGP03.phx.gbl...
>
"JCCDevel" <JC******@gmail.comwrote in message
news:69**********************************@d21g2000 prf.googlegroups.com...
>Hello,

I'm working on a pretty simple web app in which the user will be
pasting in a list of values (letters and number - like "1V456") most
likely from an Excel worksheet. I then want the application to check
this list against tables in a sql server database for different things
(like - does it exist in database, etc.) My co-worker thinks that a
richtextbox is the best control to use for this. I'm new to VB.Net so
I'm not real familiar with this control. Is it the right way to go?
I've been doing a little research on the web and don't see it used too
much for this situation. I have been playing with it a bit and have
gotten results to point to a table, but it is adding in strange
characters and blank entires. Here is the code:

<code>
For Each str As String In RichTextBox1.Lines
InsertSQL = "Insert into Test_test values ('" & str & "
')"
dr1 = SqlHelper.ExecuteReader(CONNSTRING,
CommandType.Text, InsertSQL)
Next

</code>

Is a "For each" statement the way to go?

Thanks in advance for your time!


I don't see any problems in what you're doing. Does it work for you?
That's all that counts is that it works for you. There several ways that
one could possibly do things, but just use the one you are using.

I would stick with what you got.

However, you need to do a SqlBless function on the str SqlBless(str) on
that Insert statement, because special characters can be in that str that
can make the Insert terminate, if they are not accounted for on the
Insert.

You can use Google to lookup SqlBless and apply the function in your
program.

>>
JCC
You should be using parameters to execute your SQL statement.

InsertSQL = "Insert into Test_test values (@InsertValue)"

Then you are executing using a datareader. Since you are not reading
anything use ExecuteNonQuery

LS

Dec 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1810
by: Pramod | last post by:
Hi All, I am working on C# windows Application. I want to draw a rectangle on a richtextbox and write some text inside the rectangle, like this many rectangle should be drawn at the user choice....
10
11597
by: D Steward | last post by:
I can't seem to add a newline (/n) to get a richtextbox control to display text on successive lines. The text that I type is overwritten. How do I remedy this My example richTextBox->Multiline...
0
2065
by: y2k692hu | last post by:
Hello I am trying to run this and I keep getting a "SystemNullReferenceException: Object reference not set to instance of an object" error. I have three menu items bold, italic and underline. When i...
0
1467
by: steve | last post by:
Hello, I have been working on this piece of code that's supposed to read from a file - transform - preview and finally save the transformed data. I can read the file and with...
0
4130
by: John Smith | last post by:
I have text files and I get binary offsets of text portion of these files from VB6 program with RichTextBox. I use VB.Net 2003 and need to select and highlight the text between given offsets....
8
3249
by: AxOn | last post by:
Hi, How can i save the specific RichTextBox in the selected tab if i have several tabs with RichTextBoxes in? The application is a text editor type program and when i try to save the most...
8
8481
by: Paul | last post by:
Hi, My VB is very rusty I'm afraid! What would be the most efficient way to remove the following ASCII characters from a string? à è ì ò ù À È Ì Ò Ù á é í ó ú ý Á É Í Ó Ú Ý â ê î ô û Â Ê Î Ô...
2
1782
by: good1030 | last post by:
Hi to everybody, I have 4 RichTextBox in my program, how can i loop these 4 RichTextBox with the field names, like: for (i=1;i<=4;i++) { do something to richTextBox(i); } Thanks in...
0
2520
by: dannyboy1990 | last post by:
I've been developing in vb.net for a few months now, well since i left school and one of my projects for my current company is to create a sql tool which is used on a daily basis to update, delete...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7126
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,...
0
7175
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...
0
7330
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...
0
5434
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,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
262
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...

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.