I will use Tutorial 9 as a base of the following solution.
1. Open the Tutorial 9 project and open the designer of Form1.
2. Right-click on 'itemTableAdapter1' and select 'Add Query...' from the context menu.
3. In the dialog that appears add the following parametrized query in the 'Query Text' text box:
SELECT Item.*
FROM Item
WHERE Item.StartTime>=? AND Item.EndTime<=?
Make sure that 'New query name' is selected and use the default name for the new query - FillBy. Click 'OK'.
4. Navigate to the event handler of the 'Load' button and make the following modification of the event handler's code:
// itemTableAdapter1.Fill(plannerDataSet.Item);
itemTableAdapter1.FillBy(plannerDataSet.Item,
new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
What we are doing above is that we comment the code that loads all items using the default select query of the Item table adapter and instead use the newly created parametrized query. The specified start and end time are completely exemplary. You should use start and end time that meets your criteria.
5. Run the application and try loading the items using the new method.
Regards,
Meppy