Reading Database Feilds

Bigbadborris

Active member
Joined
Aug 21, 2013
Messages
35
Programming Experience
Beginner
Hi All

My company runs a DOS based system that I am slowly changing over to VB.net. We have a stores system that creates a build list for parts that need to be constructed in the workshop. Each build list for a Part has its own part number, and each build list can have a maximum of 50 other parts that come together to create the piece of equipment. The DOS system stores the individual parts required and the quantities needed like this 233C/2 The First 4 characters are the Part Number and the number after the slash is the quantity required. I have an access database table called BUILDS that has 51 Colum's the first is for the Build List Part Number and the rest are for the individual parts. I have managed to import all the builds and parts from the DOS created text file into the database ( 1 record per Build List )

What I am trying to do is when the user enters the required Build List Part number in a text box (txtSearch) the program searches the table and returns all the parts to variables so that I can then split the string to allow me to search the main stores program for the part number ( first 4 characters ) description and the display the complete build list as shown.

Part Number Desc QTY Per

232C NUT 2
265C BOLT 2
545A WASHER 2

I don't really want to have to assign each field and variable as there could be a maximum of 50 separate parts required, the program would be massive...

Can anyone help with an easier way to do this. The DOS system has over 20 years worth of data I really don't want to have to re input it all manually.

Many Thanks
 
That's exactly what loops are for. If you have 50 fields then you use a For loop with 50 iterations. Inside the loop, you would get the value of the field at the current index, split it, get the appropriate data and then put it in the appropriate place, also by index. You would probably put all the pry numbers into a single string and than use an IN clause in your SQL code to get all the part records in one go.
 
That's exactly what loops are for. If you have 50 fields then you use a For loop with 50 iterations. Inside the loop, you would get the value of the field at the current index, split it, get the appropriate data and then put it in the appropriate place, also by index. You would probably put all the pry numbers into a single string and than use an IN clause in your SQL code to get all the part records in one go.

That makes a lot of sense thank you. I dont have much experience in using loops, to save alot of time searching do you know of any tutorials or examples I can look at to learn from. Cheeky i know.

Many Thanks
 
Back
Top