auto generate number in asp.net which is auto add in sql server table with other data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jagdish Patil
    New Member
    • Mar 2011
    • 1

    auto generate number in asp.net which is auto add in sql server table with other data

    I have project in asp.net with sql server backend.
    i want to auto generate a number for particular column.
    with the auto generated number i want to insert some other data in the same row same table. on button click event.

    details
    railway PNR no.:- want to autogenerat
    passenger details:- want to inserted simultaneously

    pls help me
    jagdish_contact 27@yahoo.co.in
  • VijaySofist
    New Member
    • Jun 2007
    • 107

    #2
    Hi,

    Using SQL Server - In Table Design Set that "PNRNo" Column as Primary Key and Set IsIdentity=Yes

    At the End of your Insert query Add the Following Line

    Code:
    Select @@identity;
    - This Will Return the PNRNo Value. Using this value you can use the update query.

    If this is not the answer you expected, Post your Code here.

    Regards
    Vijay.R

    Comment

    • silwar
      New Member
      • Mar 2011
      • 7

      #3
      1. for PNR column choose data type numeric.

      2. Go to Column properties window and expand Identity specification option.

      3. Where it is written Is Identity select yes.

      4.In the same menu you can also provide Identity increment for how much it increments every time e.g. If you want to increment value by 1 number every time data is recorded put value 1.

      5. you can also set starting seed so that you don't have to do that manually. e.g. put 101 if you want first record should have pnr no = 101

      Comment

      Working...