TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > VB.NET

Notices

RichTextBox - the correct choice and how to loop

VB.NET


Reply
 
Thread Tools Display Modes
Old 15-12-2007, 12:20 AM   #1
JCCDevel
Guest
 
Posts: n/a
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
  Reply With Quote
Old 15-12-2007, 04:11 AM   #2
Mr. Arnold
Guest
 
Posts: n/a
Re: RichTextBox - the correct choice and how to loop


"JCCDevel" <> wrote in message
news:...
> 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


  Reply With Quote
Reply

Thread Tools
Display Modes



< Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT +5.5. The time now is 05:56 PM.


vBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2009, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional