|
-- Posted by Rhapsody at 5:56 pm on June 17, 2009
I am required to write a program for my end of year project and right now I am at somewhat of a writers block. I have this idea but I just can't seem to be able to put together the code for it or I am too lazy to attempt it. It is the final part of my project and once I have finished it, then my program will be considered finished. The General idea is that when I select a supplier from the list using the combo box located in the top left hand corner, a search is performed and the boxes underneath are filled with the information from the database. But they should only be filled in this case with items and only 8 items at a time will need to be filled. So i need to program it in a way where it will stop after the first 8 and when the NEXT BATCH button is pressed the next 8 items from that supplier are filled in, clearing the previous set.
-- Posted by Mods1Blow2Me3Daily at 5:57 pm on June 17, 2009
are you using j-creator?
-- Posted by Rhapsody at 5:59 pm on June 17, 2009
Quote: from Mods1Blow2Me3Daily at 8:57 pm on June 17, 2009
are you using j-creator?
Lemme see, Topic Title: Database in Visual Basic, so taking a wild guess based on the topic title, I'll just assume that I am using Visual Basic. And I did not mention anything about it being a java program either.
-- Posted by JamesBrauman at 6:05 pm on June 17, 2009
Okay. Think about it this way - each 'batch' is a different page. So have a variable to hold the page number, you'll want to initally set it to zero. Each time the 'next batch' button is pressed you'll want to increase this number. I'm not sure how you are accessing the database, but by having this variable it is easy to get each 'batch'. What you need is to be able to select which item numbers you want to get out of your database. Normally (with SQL for example), you tell the database the record to start at, and the record to end at, and it selects all the records between those two (including the start and end.) Now you know you only want 8 items per page. So the difference between each start and end number needs to be 8. So if you're 'starting number' was 0, and your 'end number' was 8, it would select records 0-8. So you'll need two more variables, lowerLimit and upperLimit. Whenever the next batch button is pressed, you need to: - Increase the 'batchNumber' by one. - Make 'lowerLimit' equal to batchNumber * 8. - Make 'upperLimit' equal to (batchNumber + 1) * 8. Then you can just do something like this (this is SQL): SELECT * FROM your_table LIMIT lowerLimit, upperLimit. Edit: Similarly, for previous batch, all you need to do is recude 'batchNumber' by one, and then evaluate lowerLimit and upperLimit again. I hope this has helped.
-- Posted by Rhapsody at 3:23 am on June 18, 2009
For anyone interested, I took the lazy way out. I just used the Data Control and the Data grid along with a combo box and a SQL statement and achieved the goal.
|