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)
Printable View
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)
Try using Identity.
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.
i've done that, now will check if it real works , ty all :D
k nevermind..its working now
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.