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)

            txtMovieNamesearch.Focus()
        Else
            MovieName = "select * from Movies  WHERE (Movie Name='" & txtMovieNamesearch.Text & "')"
            MoviesTableAdapter.FillByMovieName(_I_Spot_MoviesDataSet.Movies)

        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!!

Recommended Answers

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) & "'%"
Jump to Post

All 3 Replies

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) & "'%"

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?

check the DataSource of the DataGrid

Be a part of the DaniWeb community

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