Results 1 to 3 of 3

Thread: SQL - How do I update with a Unique Column? - Urgent!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    258

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member snakeman's Avatar
    Join Date
    Aug 2006
    Posts
    351

    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
    Last edited by snakeman; Mar 31st, 2009 at 07:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width