468,167 Members | 1,862 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,167 developers. It's quick & easy.

Can someone explain this code for me pls!

markmcgookin
648 Expert 512MB
Hi Folks,

this may seem very lazy, but can someone exaplin this bit of code for me?

regID int IDENTITY(0,1)

It is part of an SQL CE command in a VB app, but I just don't get what the regID in IDENTITY (0,1) is in there for.

the full code is

Expand|Select|Wrap|Line Numbers
  1.  'Create SQL command to create the tblDetails table
  2.  
  3. Dim cmdTabla As New SqlCeCommand("CREATE TABLE tblDetails(regID int IDENTITY(0,1) PRIMARY KEY, Flower_ID NTEXT, Name_Eng NTEXT, Name_Lat NTEXT, Location_ID NTEXT, Habitat_ID NTEXT, Season_ID NTEXT, Family_ID NTEXT, Size NTEXT, Description NTEXT)", conn)
  4.  
  5.  
Sorry I havent trimmed the code for the window, don't really think it matters here.
Feb 26 '07 #1
5 1197
willakawill
1,646 1GB
Hi. This statement is using CREATE TABLE and refers to one of the columns in the new table, tblDetails
regID int IDENTITY(0,1)

regID is the name of the column
int is the data type
IDENTITY means this is an autonumber or auto-increment field
(0,1) the zero is the seed or starting number. The one is the increment, i.e. each new record will increment by one.
Feb 26 '07 #2
markmcgookin
648 Expert 512MB
regID is the name of the column
int is the data type
IDENTITY means this is an autonumber or auto-increment field
(0,1) the zero is the seed or starting number. The one is the increment, i.e. each new record will increment by one.
Hi, I understand the create etc.. However when I open the table in SQL Server CE the Reg "column" that it appears the code creates does not appear as a standard column, I created multiple tables and from what I gather the

CREATE TABLE **TABLENAME** (regID int IDENTITY(0,1) stays the same for each one. However it seems to produce different values for the Identity/reg in SQL viewer.

I am not even sure if this is important to my system design, I just like to understand all my code, and don't see why I am including this. Just wanted to know why it was there.
Feb 27 '07 #3
willakawill
1,646 1GB
An identity column is not a standard column. You cannot update it. It is controlled by the database.
Feb 27 '07 #4
markmcgookin
648 Expert 512MB
An identity column is not a standard column. You cannot update it. It is controlled by the database.
Ah so is it just one of those things thats there that you shouldn't ask about? It works .. so don't touch?
Feb 27 '07 #5
Killer42
8,434 Expert 8TB
Ah so is it just one of those things thats there that you shouldn't ask about? It works .. so don't touch?
Not at all. You should understand the tools you're working with. It's just that in this case you are defining a field with parameters that indicate the database software should provide the values automatically, so you cannot update the field.
Feb 27 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by J Allen Horner | last post: by
4 posts views Thread by Ravi | last post: by
6 posts views Thread by Dave Young | last post: by
1 post views Thread by gcdp | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.