Simple ADO.NET search, filter data entry form 1.X
Posted on 2007-03-26
I know this isn't difficult, but I've been looking for a clear example or solution to get this to work for a while and I need some expert advice, or someone to point me to a good example. ADO.NET 1.X only, I am using Visual Studio 2003
I need some guidance on how to properly setup a VB.NET WinForm with Search/Filter functionality.
I have successfully setup a connection to SQL Server and I can navigate through all my records, edit them, update them etc. I navigate using this sort of statement, where objdsSales is an instance of my dsSales Dataset.
Me.lblNavLocation.Text = (((Me.BindingContext(objdsSales, "sales").Position + 1).ToString + " of ") _
+ Me.BindingContext(objdsSales, "sales").Count.ToString)
Everything works fine except I can't grasp how to filter or search for subsets of my DataSet. I want to use SQL statements to bring up specific records, or groups of them and have my controls automatically filled in with that data. For instance, if they want all records starting with an order number of 1, I want to use an SQL statement to get those records, and be able to navigate through that subset and view/update them.
I have tried finding a record in a dataview, sorted by my primary key and then getting that index value and changing my position in the main form.
Me.BindingContext(objdsSales, "sales").Position = FoundIndex
That works except I cant filter by multiple records. What should I be doing?
Thanks in advance for the help.