Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

vb.net - Searching button doesn't work when i click

when I type "Sang" in textbox , the table doesn't show the Judul Buku with "Sang" word in the table. This is the picture when I clicked the Search Button

This is the code in Search button :

Private Sub TsSearch_Click(sender As Object, e As EventArgs) Handles TsSearch.Click
    If TxtKeyword.Text <> "" Then
        TBL_BukuTableAdapter.FillByJudulBuku(UASDataSet.TBL_Buku, TxtKeyword.Text)
    End If
End Sub

I also add the Search Button in the Query.. Picture of Query Code

question from:https://stackoverflow.com/questions/65859361/searching-button-doesnt-work-when-i-click

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have one too many @ symbols in your WHERE clause

WHERE (@Judul_buku LIKE '%' + @Judul_buku + '%')

With this statement, you are comparing the parameter with itself, this will always be true, therefore all of the rows in the table will be returned.

You should remove the first @ symbol to refer to the column and not the parameter, like:

WHERE (Judul_buku LIKE '%' + @Judul_buku + '%')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...