Juan Velasquez
asked on
Creating a Dynamic TableAdapter
Hello,
I have the following form which use the following combo boxes to filter the dataversionid listbox
1. Filter by Budget Year
2. Filter by Input Code
3. Filter by Technology Set
I want to avoid creating nine different methods in the underlying table adapter. I would need to create nine getdata methods in order to take into account all possible selections of comboboxes that user may make selection from. Below is the type of code I originally had in mind. But it seems to me, there should be a better way. Thanks
I have the following form which use the following combo boxes to filter the dataversionid listbox
1. Filter by Budget Year
2. Filter by Input Code
3. Filter by Technology Set
I want to avoid creating nine different methods in the underlying table adapter. I would need to create nine getdata methods in order to take into account all possible selections of comboboxes that user may make selection from. Below is the type of code I originally had in mind. But it seems to me, there should be a better way. Thanks
If cboBudgetYear.SelectedIndex > -1 Then
Dim intSelectedYear As Integer = Convert.ToInt32(cboBudgetYear.Text.Substring(0, 4))
Me.CommentsTableAdapter.FillByBY(Me.BADSDataSet.Comments, intSelectedYear)
MessageBox.Show(intSelectedYear.ToString)
Else
Me.CommentsTableAdapter.Fill(Me.BADSDataSet.Comments)
MessageBox.Show("No Budget Year Selected")
End If
GraphDesigner.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello Code Cruiser. I went ahead and went the stored procedure route. I created a procedure that takes the user selections as optional variables and via a series of conditional statements returns the correct set of records. I'll will use this stored procedure to filter the dataversionld listbox via the fill method of the underlying data adapter.
That's great. Stored procedures are the best option in speed, performance, network traffic, and security aspects.
ASKER