Results 1 to 6 of 6

Thread: how to create auto increment columns?

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    how to create auto increment columns?

    i have a primary key (its an INT) and i want to set it to auto increment..how can i do this? (thru SQL server enterprise manager or vs.net if possible)
    \m/\m/

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Try using Identity.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Set the Identity property of the field to Yes. That should set Identity Seed to 1 and Identity Increment to 1 also. Then it will be an autoincremental field.

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i've done that, now will check if it real works , ty all
    \m/\m/

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    k nevermind..its working now
    \m/\m/

  6. #6
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    This is my experience withy SQL Server identity fileds (sqlDatadapters) and its comparison with oledbdatadapter.
    Imagine your database table has two fileds, one ID (autonumber or Identity with seed=1) and one column called 'name'
    I did these two:
    1- Added an oledbadatadapter, generated the dataset, added values to dataset ('name' filed) and updated the database. Everything works fine, no problem with AutoNumber Field.

    2- Added a sqlDatadapter, generated dataset, added values to dataset ('name' field) and updated the database in sql server. It fails with exception regarding the filed to be unique. So it seems that when you generate the dataset from the sql server database the Identity filed in dataset will not have the same property of that in sql server table. It will not autoincrement at all (At least thats what I think). So you have to set the following to avoid conflicts.
    VB Code:
    1. myds.mytable.columns(myautonumberfield).AutoIncrement = True
    2. myds.mytable.columns(myautonumberfield).AutoIncrementSeed = -1
    3. myds.mytable.columns(myautonumberfield).AutoIncrementStep = -1

    Correct me if i am wrong.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

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