Using the same query to find data with different criteria selected by user

Joined
Sep 3, 2008
Messages
19
Programming Experience
1-3
I have created a form with the following textboxes:

- Customer Name
- Address
- Telephone #
- Customer ID
- Postal Code
- Birth Date


This form allows the user to search for records using values entered in the textboxes. Assume a user enters a customer ID and presses the find button. The code written in this problem uses ADO.Net to access data in a MS Access 2007 database. When the program finds the record that matches the entered customer ID, the record will be shown on the form. After this search, assume the user presses the clear button on the form which then causes the Customer ID textbox to clear. After doing this, the user wants to find another record using a different customer ID. After entering the second customer ID and pressing the find buttom, the program shows the same results as the one for the first search. I have not declared a new data adaptor nor have I declared a new dataset for the second query. I'm using the same data adaptor and dataset that was used for the first query but with different search criteria. How can I overcome this problem? That is, how can I use the same data adaptor and dataset for retrieving a record using the same SQL statement but with a different search criteria (i.e. different customer ID value).

Thanks.
 
After running the query the first time do you clear the dataset before running the next query?
 
I had used the dataset clear command when the user clicks on the press button. After this, I use the data adaptor to fill the same dataset with the new query results. The dataset does clear but I can't get a new set of query result to go into the same dataset for viewing. How can I overcome this problem?
 
Can you perform the search from any of the text boxes or just the ID? If from any then search once from the ID, then try searching from one of the other text boxes. Are you sure the query is taking the new parameters for the search?
 
So then right now you are only searching a query based on the customerID, right? So when you try a new search, have you checked that the query is using the new ID for the search and not the original?

Paste your code that you are using in here so I can see what you are doing.
 

Latest posts

Back
Top