• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Need help in changing the underlying SQL for a DataGridView

Hello,

I need a way to change the SQL statement that is being applied to the DataGridView but I am not sure how to go about it. Do I need to apply it to the Table Adapter, the Binding Source or the Dataset?

What I want to do is have a combo box, text field and a button to apply filtering of the data on the fly. The operator will select from the combo box which field to search, then enter the search term and press the button to apply it.

Thanks
0
dijon316
Asked:
dijon316
  • 2
1 Solution
 
SanclerCommented:
It sounds like you should use the .Filter property of the BindingSource.  It takes a String, which you could build "on the fly" on these lines

   Dim FilterString As String = <fieldnameselectedfromcombo> & " = '" & <textfromtextbox> & "'"
   MyBindingSource.Filter = FilterString

Roger
0
 
dijon316Author Commented:
It ssems when I apply the filter, nothing changes. Do I need to refresh something to cause the DataGridView to update?
0
 
dijon316Author Commented:
Nevermind, I was trying to asign the code to an unused button. It did work. Thanks!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now