SQL and its primary key

  • Thread starter Thread starter Peace
  • Start date Start date
P

Peace

Hi I attempted in a database update to autoincrement the primary key this
way:

Dim i As Integer = 1
Dspostings1.Postings.PostIDColumn.AutoIncrement = True
Dspostings1.Postings.PostIDColumn.AutoIncrementSeed = -1
Dspostings1.Postings.PostIDColumn.AutoIncrementStep = -1

but the value returned as -1

Also there is hold over data (highest number 54) in the database that was
imported. My hope was it would use the next number (55) when creating the
record.

What did I do wrong? This did work in access.
 
When is it -1? After you fire the update? How are you getting the data
back once you fire the update?
 
Hi Bill,

Its scorp how are you today.

Anyway, it entered into the database as -1. The next test I did it entered
the record as 1. So the previous records I changed one of the values to read
2 hoping it would skip that record and name it 3. It didnt bombing out
because it was an "identical record".

I went into SQL Server Manager and opened the table to verify and sure
enough the record was -1 followed by 1.

Thanks for your help.
 
Hello Scorp

Do you have the Field in SQL-Server set to Identity type? ADO does not
handle the sequencing. SQL-Server does. In order to get the field to
increment you have to set it to Identity.


--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================
Pocket PC Return On Investment Calculator
Free Download http://64.78.34.175/mcsnet/kwickKalk1.aspx
 
Hi

I put the table in design view, right clicked and selected the PostID column
and made it and said the table identity column was PostID.

It is now complaining that identity insert is off. Do I need to regenerate
the datasets and adapters in Visual Studio?
 
Problem solved after regeneration of dataset.

Peace said:
Hi

I put the table in design view, right clicked and selected the PostID column
and made it and said the table identity column was PostID.

It is now complaining that identity insert is off. Do I need to regenerate
the datasets and adapters in Visual Studio?
 
Back
Top