Randomizing a database

I am very lost. I am not sure this a begginer question, or if I am posting in the proper place. Additional this is NOT a home work project, the example I use below is just that, an example and not exactly what I am doing...

Ok, so here is what I am doing. I want to write a program in visual c++ 6.0 that will take a data base I have built in access and read the information in randomly, excluding certain entries based on user input.


For example, let’s say that my data base had apples, oranges, peaches, and pears with a price for each one. In the program, the user could enter the total amount of money they want to spend, and they could click check boxes to include apples, oranges, and peaches but not pears (or whatever). When they hit generate I want the database to load into the program and it randomly generate how many apples, oranges, and peaches the person can buy for the total they entered, by subtracting the price from the total they enter. So some times it may generate 6 apples, 3 oranges, and 1 peach and the next time the click generate it may output 2 apples, 5 oranges and no peaches, and the next time it may simply say 9 peaches; all the while excluding pears as that check box was not checked.

I created my database in access and used ODBC but am not sure this is going to work as I want the program to work on any computer I install it on. I seem to recall that ODBC data bases are computer dependant. I am unsure as to whether if I add the data base into the install shield pro builder, at the time I create my setup.exe file, that when the end user installs the program and runs it, the program will be able to access the data base.

So my first question is should I be using ODBC for the data base or ADO or is there a better way to do this?

My next issue comes in that I want to read the file multiple times having the price of the fruit subtracting each time until the total remaining of the users input is less that the price of any of the fruit – but I don’t want the same result each time. The user should not put in $7 and get 5, apples, 3 oranges and a pear every single time they click the button. I was thinking of setting up a while loop and have it repeat until the user’s input is less than the lowest value of lowest priced fruit, but I don’t believe that would work as, if the user uncheck the box for that fruit, it would never exit the while loop and display the results. So, I am completely lost as to how to code this to do what I need it to do.

The user input of course will be coming from edit boxes and the output will need to be displayed in mutiple static text boxes. I'll have a box for how many of said item, the name of said item and a desciption of said item for each fruit. The static text boxes will be hidden until the results are generated and then only the boxes with results should be displayed. So for my example from above of a result of 2 apples, 5 oranges and no peaches,all the while excluding pears as that check box was not checked should only give:
[2] [apples] [red colored]
[5] [oranges] [orange in color]

I am using [] to represent the static boxes.


Keep In mind, the example above is not actually the input I am using, just a generalized break down. I actually have quite a number of “apples, oranges, etc” check boxes, which eliminates me from the simple solution of hard coding the options. Any help from any one would be greatly appreciated.



Topic archived. No new replies allowed.