fill table from combobox parameter
I have a form that I can fill, navigate update, and edit etc with no problem.
One of the columns in the dbtablethe form picks up from is "department" and I would like to be able to limit the data that gets returned into the datatable to the department chosen in the combobox. I can do this by adding the WHERE "department" =? and then setting the parameter to ? from the combobox.
My problem is if i want to fill the dataset with all data regardless of department how do i do that? I was hoping I could set the ? as % and that would select everything but of course it didn't.
Is there an easy answer or a better approach i should consider?
Many Thanks
Scott
Re: fill table from combobox parameter
Use LIKE instead of = in your SQL statement. LIKE behaves the same as = if the value has no wildcards. So your SQL should be "WHERE department LIKE ?" and then you would set the parameter value to "%" to retrieve everything. An alternative may be to just retrieve everything in the first place and then just set the DefaultView.RowFilter property of your DataTable to filter the data displayed based on the selection in your ComboBox.
Re: fill table from combobox parameter
wow you get about! every .net forum ive been on I see your name helping everyone. respect to you!
I knew of LIKE but didn't know the wild card worked with it. I will try it out! if not i will try your other sugestion.
Thanks for your help
Scott