You would add the recordset to the page with the add to cart button that filters based on the product and quantity and use the filtered recordset to set the price.
The easiest fix is to then not allow quantity update on the add to cart page so that they would have to remove and add again from the add to cart page to change quantity.
In order to allow quantity update you would have to manually code a loop when the cart is updated that would check the database and update the quantity when necessary. We could help with this in a premier ticket if you have trouble with the hand coding.