I Use visual Basic 8.0 and Mysql 5.0
I have one Table1:
Table1:
RecordID , Integer = primary key auto_increment NOT NULL
Articlenr , Integer
Articlename, Char(20)

Table1: has nine records:
RecordID, Articlenr ,Articlename
1 , 1100, Hamer Big Red
2 , 1110, Hamer Big Blue
3 , 1120, Hamer Big Yellow
4 , 1200, Hamer Medium Red
5 , 1210, Hamer Medium Blue
6 , 1210, Hamer Medium Yellow
7 , 1300, Hamer Small Red
8 , 1300, Hamer Small Blue
9 , 1300, Hamer Small Yellow

Use Datagridview en textbox1.txt

I would if I type in the item number in textbox1.txt in data grid view slow the correct article appears.

Example:
If i type number 11 in the textbox1.txt than datagridview shows:
1 , 1100, Hamer Big Red
2 , 1110, Hamer Big Blue
3 , 1120, Hamer Big Yellow
If i further expanding number with 10 result is than
1110 in the textbox1.txt than datagridview show only Hamer Big Red.

Dim MyCommand1 As New MySql.Data.MySqlClient.MySqlCommand
Dim Myadapter As New MySql.Data.MySqlClient.MySqlDataAdapter
Dim MyBuilder As New MySql.Data.MySqlClient.MySqlCommandBuilder 
Dim MyDataTable As New DataTable
MyCommand1.CommandText = "select * from Table1"
MyCommand1.Connection = conn
 Myadapter.SelectCommand = MyCommand
Myadapter.Fill(MyDatatable)
DataGridView1.DataSource = MyDatatable

Thanks in advance,

Andre

I found the solution!! Here It is:

myAdapter1.Fill(MyDataset1, "table1")
MyDataTable1 = MyDataset1.Tables("table1")
 DataGridView1.DataSource = MyDataTable1
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim keywords As String = Val(TextBox1.Text)
        MyDataset1.Tables("table1").DefaultView.RowFilter = "articlenr like   '*" & keywords & "*' "
         End Sub

But the articlenr must my a string field!!!

But one problem remains open!
How can I do the same with a numerical field {articlenr}.
So I want a Rowfilter => articlenr like TextBox1 (input)
I want to use LIKE operator!!!
Who knows the answer to this problem?

I found the solution myself!!!
Is simple:

MyDataset1.Tables("table1").DefaultView.RowFilter = "Convert(articlenr , 'system.string') like '*" & keywords & "*' "

Be a part of the DaniWeb community

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