Hi guys....longtime:) Am working on a movie rental system in VB.NET, but there's a problem. I want a situation whereby the user will have the privilege to search for desired records by typing a search string, then hitting the search button. The results should be shown on a datagridview. Here's my code:

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

        Dim MovieName As String

        If txtMovieNamesearch.Text = "" Then
            MessageBox.Show("You must enter the name of the movie you want to search!", "I-Spot Movies", MessageBoxButtons.OK, MessageBoxIcon.Error)

            MovieName = "select * from Movies  WHERE (Movie Name='" & txtMovieNamesearch.Text & "')"

        End If

    End Sub

When i type a search string in the textbox and then i hit the search button, all the records disappear :( please help!!

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

7 Years
Discussion Span
Last Post by ohunwujolly

is the data being stored is case sensitive ?

Better to use LIKE inplace of = for character search.

try something like this

"select * from Movies WHERE upper(Movie_Name) like %'" & upper(txtMovieNamesearch.Text) & "'%"

Edited by debasisdas: n/a


I've inserted the line of code, but the problem still persists...the datagridview does not show the filtered records. How do make it display the filtered records?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.