0

Hello...
Im having a problem with "like operator" on SQL database

Im using this code to search on database

    Dim DV As New DataView(dbDataSet)
        DV.RowFilter = String.Format("ID Like '%{0}%'", TextBox1.Text)
        DataGridView1.DataSource = DV

and at textbox1 I type 2
in data grid view show all people who have number 2 at their ID

how to make it search EXACTLY the some id as the textbox ?

3
Contributors
4
Replies
15
Views
3 Years
Discussion Span
Last Post by altjen
0

after did like that
it show this problem

"An unhandled exception of type 'System.Data.SyntaxErrorException' occurred in System.Data.dll

Additional information: Syntax error: Missing operand after '=' operator."

this is the code

Dim DV As New DataView(dbDataSet)
        DV.RowFilter = "ID = " & TextBox1.Text
        DataGridView1.DataSource = DV
0

What data type is ID in your database?

Can you debug your code, copy and paste the SQL statement and execute it directly against the database - in SQL Management Studio for example - and see what happens. This will give you a much clearer idea of what may be wrong.

0

the code work, well. found an other idea(a bit more complicated) to correct the mistake

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.