Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have Textbox4 as a code search and filtering and it was successfully filtering in datagridview1 but in same form i have Richtextbox1 to show Datagridview1 value to showing this large text in Richtextbox1 but when search and filtering this data in textbox4 filtering happened and successfully showing in datagridview1 but Richtextbox1 not showing this value...

What I have tried:

Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
        con.Open()
        Dim dt As New DataTable
        Dim ds As New DataSet
        ds.Tables.Add(dt)
        Dim da As New OleDbDataAdapter
        da = New OleDbDataAdapter("Select *from SONGS where CODE like '%" & TextBox4.Text & "%'", con)
        da.Fill(dt)


        DataGridView1.DataSource = dt.DefaultView

        con.Close()
    End Sub
Posted
Comments
ZurdoDev 11-Nov-19 14:18pm    
What are you asking us to do?
Richard Deeming 12-Nov-19 10:03am    
da = New OleDbDataAdapter("Select *from SONGS where CODE like '%" & TextBox4.Text & "%'", con)

Don't do it like that!

Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]

da = New OleDbDataAdapter("Select * from SONGS where CODE like ?", con)
da.SelectCommand.Parameters.AddWithValue("Code", "%" & TextBox4.Text & "%")
Member 14621280 15-Nov-19 5:50am    
Thanks for the valuable code.... my question is

1. Code searching and filtering it was successfully happened in Datagridview1
2. In same form i have Richtextbox1 which is contain long text will show here
3. when i normally click the datagridview1 row content it was successfully showing in richtextbox1 but when i search through code it won't show in richtextbox1 but filtering happened in datagridview1.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900