locked
How to automatically increment an ID column? RRS feed

  • Question

  • User732704340 posted

    Hi, I have a table, which consists of bookingID, month, day, time where bookingID is a primary key. I need to update bookingID +1 every time I add a record to the table. How can I do this in VS2008 and C#?

    Friday, May 13, 2011 2:50 PM

Answers

  • User-321300854 posted

    Try setting the Identity Specification of the bookingID column to Yes. To do this with VS, open up your database with Server Explorer, right-click on your table, and click Open Table Definition. Select your bookingID column, find Identity Specification in Column Properties, and change it to yes.

    Hope this helps!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 13, 2011 4:06 PM

All replies

  • User165519407 posted

    Make that column as Identity

    Friday, May 13, 2011 4:05 PM
  • User-321300854 posted

    Try setting the Identity Specification of the bookingID column to Yes. To do this with VS, open up your database with Server Explorer, right-click on your table, and click Open Table Definition. Select your bookingID column, find Identity Specification in Column Properties, and change it to yes.

    Hope this helps!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 13, 2011 4:06 PM
  • User732704340 posted

    It's solved now. I've change column form varchar(50) int and set its identity specification to yes so now it increments automatically.

    Thanks for help 

    Saturday, May 14, 2011 7:57 AM