Easy One: How do I populate a RichTextBox with a cell from SQL Server?

Here is the code that I am using,

        Dim sqlcom1 As SqlCommand = New SqlCommand("SELECT * " & _
                                        "FROM TABEL1 " & _
                                        "WHERE VAR1 = '" & cmb_VAR1.Text & "'")
        Dim reader_recode As SqlDataReader
        reader_recode = sqlcom1.ExecuteReader
        While reader_recode.Read
            rtb_DATA1.Text = reader_recode("DATA1")
        End While

I get an error when using Option Strict On.  If I turn that off, things are fine, but I would like to code this correctly.

Here is the error:

Option Strict On disallows implicit conversions from 'System.Object' to 'String'.

Any ideas?
Who is Participating?
Jeff CertainConnect With a Mentor Commented:
You might try:

rtb_DATA1.Text = reader_recode("DATA1").ToString
reader_recode.getvalue(0) replace the 0 with the number of the field u are trying to get. This is really the proper way of using the reader.

0 example

say u have a table with the following fields
field1 field2 field3

and u want field 2 u would replace 0 to 1

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.