How do you create a new class object and add data to it from a database?
I have a table(tblCars) in a database and would like to loop through each row(Using sqldatareader?) and create a new object named after the primary key(Registration number), then add data to it from the other columns.
So instead of this:
carClass car1 = new carClass();
car1.registration = "RT11 HWY";
car1.make = "Ford";
It would be something like:
//connection and reader stuff
carClass <registration> = new carClass();
<registration>.registration = column1;
<registration>.make = column2;