Matching records in 2 tables

Jan 28 2010 12:10 PM

Hello,
Please forgive me as I feel this is a simple issue but one I have been unable to find an answer to. If there is already and answer posted to this then please direct me to it.
I am new to C# but need to learn it to maintain a stock system we have inhouse. I recently had a simple data issue that I decided to list using C#.
We have a scanned in list of barcodes from a handheld scanner, this has been uploaded into a SQL table. I need to read through this and list any barcodes that match a supplier barcode master file.
Thats it!
Now I have succeeded in connecting to the SQL database and loading the table into a dataset and can read through the dataset with no problems. My issue is when I take the barcode from the dataset and link it to the master database. What I am doing currently is loading a second dataset with any barcodes that match the one I have in my first dataset then reading through the second dataset and if the data exists outputting this to my list.
This is not how I want to do this but so far this is the nearest I have managed to get. The issue I have is with the second dataset, it keeps adding to each time I run a match query and load it from the info from the first dataset. So every time I loop round I just add to whats already there. I really want to reinitialise the dataset each time.
I have also done a straight read of the database master table but this also fails as after the first loop through(which works) it bombs with a database connection already open - I have tried to close this but it doesn't seem to matter.
This seems a very straightforward thing to try and do but I am coming from a RPG background of programming and nothin OOP before.
Any advice is very much welcomed.
By the way I have a OOP book which I am reading so am looking to change my bad old ways!.
Regards,
Roland

Answers (2)