SQL - How do I update with a Unique Column? - Urgent!
Alright, I have this Access Database. It has 6 Columns:
Code:
ID | Class Name | Class Code | Class Room | Grade | Teacher
My ID is the Unique Column that I need to reference back too when Updating my other Fields so I get the correct field.
How do I do this? Properly.
I've been thinking of a method but I doubt it would work.
First I would start off selecting all the ID's and then LOOP through all of them, and then rewrite them to to + 1 Each time I make a Delete, so Each Time it will be a consistent 1 2 3 4 5 6 7 8 9 10 .... etc... Then I can reference from that to my Combo Box Selected Index + 1 to get the Correct Row which corresponds with the Selected Item.
Will this work? Or will I still need a Unique Fields that I reference back too.
Re: SQL - How do I update with a Unique Column? - Urgent!
Why would you need to change the IDs? Why does it matter if there are gaps? You shouldn't care what the actual value is, only that it's unique.
Re: SQL - How do I update with a Unique Column? - Urgent!
hello wesley
if you binding your fields to your form (let's say you bind your ID to Textbox)
then in the Update Statement Should be like this:-
Code:
Update (Table name) Set Classname=@Classname,Classcode=@classcode,Classroom=@classroom,Grade=@grade,Teacher=@teacher where ID=@id
and then you add the values in your textboxes or any other control you use to this statement .
so the textbox that contains the id will be in the right appropriate place
i hope this help :)