0

search button for vb 2010 ultimate in access 2007 database and filtering on a datagrid


Hi all!

I am trying to make a search button which filters a datagrid. First of all, I have a tab and on this tab a have a datagrid (dgr1). When I load this tab, I fill in a dataset from the database using a data adapter and this code:

DAProjects.Fill(DSProjects.Tables("Projects"))

and then I send and display the data set to the datagrid with this code:

dgr1.DataContext = DSProjects.Tables("Projects")

Also, I have a TextBox1 and PushButton and when i Push the button I want to diplay on my datagrid only the rows which have the text that I wrote in the textbox.

I try to do this using this code but I don't know how to display (filter) only some rows from the datagrid:

Dim pro As String
Dim MaxProjects As Integer
Dim counterpro As Integer = 0
Dim asd As Integer = -1

MaxProjects = DSProjects.Tables("Projects").Rows.Count

While counterpro < MaxProjects + 1 Or asd = -1


pro = DSProjects.Tables("Projects").Rows(counterpro).Item(1)

asd = pro.IndexOf(TextBox1.Text)   

End While

Please explain to me your answer and your code because I don't have so much experience with databases and vb.

Thanx in advance!!!
sotos

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by sotos
0

PM: I use a wpf file.

search button for vb 2010 ultimate in access 2007 database and filtering on a datagrid


Hi all!

I am trying to make a search button which filters a datagrid. First of all, I have a tab and on this tab a have a datagrid (dgr1). When I load this tab, I fill in a dataset from the database using a data adapter and this code:

DAProjects.Fill(DSProjects.Tables("Projects"))

and then I send and display the data set to the datagrid with this code:

dgr1.DataContext = DSProjects.Tables("Projects")

Also, I have a TextBox1 and PushButton and when i Push the button I want to diplay on my datagrid only the rows which have the text that I wrote in the textbox.

I try to do this using this code but I don't know how to display (filter) only some rows from the datagrid:

Dim pro As String
Dim MaxProjects As Integer
Dim counterpro As Integer = 0
Dim asd As Integer = -1

MaxProjects = DSProjects.Tables("Projects").Rows.Count

While counterpro < MaxProjects + 1 Or asd = -1


pro = DSProjects.Tables("Projects").Rows(counterpro).Item(1)

asd = pro.IndexOf(TextBox1.Text)   

End While

Please explain to me your answer and your code because I don't have so much experience with databases and vb.

Thanx in advance!!!
sotos

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.