|
-
Jun 4th, 2003, 11:59 AM
#1
Thread Starter
yay gay
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/
-
Jun 4th, 2003, 12:06 PM
#2
Frenzied Member
'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
-
Jun 4th, 2003, 12:06 PM
#3
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.
-
Jun 4th, 2003, 12:12 PM
#4
Thread Starter
yay gay
i've done that, now will check if it real works , ty all
\m/  \m/
-
Jun 4th, 2003, 12:16 PM
#5
Thread Starter
yay gay
k nevermind..its working now
\m/  \m/
-
Jun 4th, 2003, 12:18 PM
#6
Frenzied Member
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:
myds.mytable.columns(myautonumberfield).AutoIncrement = True
myds.mytable.columns(myautonumberfield).AutoIncrementSeed = -1
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|