I am new in VB.NET. Can any tell me how a richtextbox query MySQL table.
i.e select * from table test where name= 'Bowser'

then the richtextbox will display the results.

Thank you!

show us your code friend..

show us your code friend..

here is the code so far, I have made MySQL connection working. now need to do the query display result on richtextbox.

----------------------------------

Private Sub cmdLogin_Click_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin1.Click
        conn = New MySqlConnection()
        conn.ConnectionString = "server=" & TextBox1.Text & ";" _
     & "user id=" & TextBox2.Text & ";" _
    & "password=" & TextBox3.Text & ";" & "database=test"
        Try
            conn.Open()
            MessageBox.Show("Connection Opened Successfully")
            conn.Close()
        Catch myerror As MySqlException
            MessageBox.Show("Error Connecting to Database: " & myerror.Message)
        Finally
            conn.Dispose()
        End Try
    End Sub

    Private Sub RichTextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox4.TextChanged

    End Sub
End Class

Now, you have to configure MySqlCommand object to execute select query against that database connection.

conn = New MySqlConnection()
   conn.ConnectionString = "server=" & TextBox1.Text & ";" _
     & "user id=" & TextBox2.Text & ";" _
    & "password=" & TextBox3.Text & ";" & "database=test"
        Try
            conn.Open()
            Dim cmd as New MySqlCommand("select colName1 from TableName where ColName2=1",cn)
            Dim obj as object
            obj=cmd.ExecuteScalar()
            conn.Close()

            IF IsNothing(obj) then
                   MsgBox ("Not found")
            ELSE
                 RichTextBox4.Text=obj.ToString()
            End IF
        Catch myerror As MySqlException
            MessageBox.Show("Error Connecting to Database: " & myerror.Message)
        Finally
            conn.Dispose()
        End Try

PS: Please read this article - http://msdn.microsoft.com/en-us/library/h43ks021%28VS.71%29.aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.