RichTextBox - the correct choice and how to loop
by JCCDevel » Sun, 16 Dec 2007 03:20:33 GMT
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
Re: RichTextBox - the correct choice and how to loop
by Lloyd Sheen » Mon, 17 Dec 2007 02:27:01 GMT
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
Similar Threads:
1.I don't believe this code gives the correct RichTextBox string size
I don't believe the code below gives the correct string size in inches.
Can any one tell me what is wrong?
I need to know the size of the string before I add it to the RichTextBox
Thanks
Public ReadOnly Property TxtMeasureString(ByVal str As String) As SizeF
Get
Dim Gr As Graphics = Me.CreateGraphics
Dim MeasureString As SizeF = Gr.MeasureString(str,
ControlRichTextBox1.SelectionFont())
TxtMeasureString = New SizeF(MeasureString.Width / Gr.DpiX,
MeasureString.Height / Gr.DpiY)
Gr.Dispose()
End Get
End Property
2.Need correct VBScript syntax for looping through form controls
Hello,
Can someone give me an example of looping through a set of checkboxes or
radio buttons on an html form, for the purpose of determining which one(s)
are selected? I usually use JS for this, but would like to use VBS and can't
make it work. Thanks.
3.Choices, choices - does Style exist?
Am Sat, 21 Oct 2006 03:28:06 UTC, schrieb "Greg Maxey"
< XXXX@XXXXX.COM > auf microsoft.public.word.vba.general :
> Sub Test2()
I would implement this as a function:
Function StyleExists (styName As String) As Boolean
Dim testName As String
> On Error GoTo Handler
testName = ActiveDocument.Styles(styName).NameLocal
StyleExists = True
Exit function
> Handler:
> If Err.Number = 5941 Then
StyleExists = False
> Err.Clear
> End If
End Function
Same applies to the existence of DocVariables and such stuff.
I just try to generalise it to any kind of collection, passing the
collection as a parameter of type Object to the function, but run into
problems. I get an error number 91.
Where do I find all those error numbers?
Yours,
L.W.
4.Choices, choices
5.Quiz in VB - Multiple choice and single choice questions
Can anyone please give me some clues on how to track the right answers
in multiple-choice type questions (using checkbox) and single-choice
questions (rdio buttons) and also how to store the right answer value
in the db?
Much appreciated
6. at runtime, get possible choices for xs:choice class
7. Does Setting RichTextBox.SeletcionStart Change RichTextBox.Text ?!?!?
8. Corrected: How do I add a "Select an item..."-choice in a databound DropDownList?