The following works with any database as at the time used we are not connected to the database at all. You can see a Microsoft article on this code.
The best way to filter is adding a BindingSource, set it's DataSource to ds.Tables[0]
then use my language extension.
public static void RowFilterTwoConditions(this BindingSource sender, string field1, string value1, string pField2, string value2, bool caseSensitive = false)
{
sender.DataTable().CaseSensitive = caseSensitive;
sender.DataView().RowFilter = $"{field1} = '{value1.EscapeApostrophe()}' AND {pField2} = '{value2.EscapeApostrophe()}'";
}
Lets call the BindingSource _bindingSource
public partial class Form1 : Form
{
private readonly BindingSource _bindingSource = new BindingSource();
Mocked up call to filter
_bindingSource.RowFilterTwoConditions(
"RoomType",
"Value from ComboBox",
"SmokingRoom",
"Value from smoking room ComboBox");
Another extension to clear the filter
public static void RowFilterClear(this BindingSource sender)
{
sender.DataView().RowFilter = "";
}