Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 848
  • Last Modified:

[C#] creating autonumber in a database

My little program creates an MS Access database with a few tables. One of the tables has a column "ID".
The creation of the database and tables is done with ADOX.

// blabla creation of db. cat = database catalog

ADOX.TableClass bla = new ADOX.TableClass(); //could be wrong. I'm at work now and do not have source here
bla.Name = "Bla";
bla.Columns.Append("ID",ADOX.DataTypeEnum.adInteger,"2");
cat.Tables.Append(bla);

What do I have to put in place of ADOX.DataTypeEnum.adInteger to get AutoNumber in the database or is there another way to that??

tnx
0
Scarfish
Asked:
Scarfish
1 Solution
 
Arthur_WoodCommented:
since 'AUTONUMBER' is an Access specific concept, I doubt that you can create an AUTONUMBER field in the table using ADOX.

Arthur Wood
0
 
RiverGuyCommented:
You could use a Create Table statement to do the whole thing, or an Alter Table statement and change if after the table is created.  Just pass the statement as an SQL statement to the Access connection.
0
 
ScarfishAuthor Commented:
What does the SQL statement looks like??

CREATE TABLE Bla
(ID ??? NOT NULL)

what do i fill in for the question marks??
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ocjaredCommented:
Create Table example...

CREATE TABLE table_name
(
autonumber  INT IDENTITY(1,1) NOT NULL,
column_name1 data_type,
column_name2 data_type,
)


Quick SQL tutorial...
http://www.w3schools.com/sql/
0
 
ScarfishAuthor Commented:
I know sql, but i didn't know how to set a column to autonumber.
0
 
RiverGuyCommented:
The word Identity means autonumber in SQL.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now