views:

1076

answers:

6

I have table in Database and the primry key is 'ID', Just I want to ask how can I make it AUTOINCREMENT

I know that's esay Q, but I dont know how can I do it.

thanks

+4  A: 

There is a property "Identity Specification". Expand that one, you can chose Increment value, and Increment Seed

Ropstah
This is for SQL Server by the way.
Ropstah
I'd bet sql server since it is asp.net
KM
I do .NET with Oracle, see my other answer. I was just assuming SQL Server somehow.....
Ropstah
I expanded "Identity Specification" and try to edit "Identity increment" but I cannt do that, becuse it's not enlighten
First change "Is identity specification" to: Yes
Ropstah
thanks, but see this pic: http://www.rofof.com/img2/6xsbuy6.gif
doubleclick NO, then it will turn into YES
Ropstah
A: 

In Sql Server define the column like this...

[PrimaryID] [int] IDENTITY(1,1) NOT NULL

Then you can add a constraint making it the primary key.

Craig
A: 

For Oracle it is a bit more trivial. You first have to create a sequence and then a trigger.

Ropstah
did you mean to say "non-trivial"?
Ape-inago
+1  A: 

Since you listed ASP.NET, I'm going to assume you are running a SQL Server 2005/2008. If you want to use the GUI, then follow these steps:

  • Open the table in design view
  • Click on the "ID" column
  • Confirm the type is an Int
  • Select "Yes" under Identity Specification
Josh
A: 

Thanks all, I use SQL Server 2005 which coming with VB.NET 2008

can you help me ?

I want a solution without writing in a code, I mean using GUI of vb.net 2008

for future reference, standard stackoverflow policy is to edit your question for clarification instead of posting an answer.
Jimmy