?
Solved

[C#] creating autonumber in a database

Posted on 2003-03-12
6
Medium Priority
?
827 Views
Last Modified: 2012-08-13
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
Comment
Question by:Scarfish
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 8121912
since 'AUTONUMBER' is an Access specific concept, I doubt that you can create an AUTONUMBER field in the table using ADOX.

Arthur Wood
0
 
LVL 3

Expert Comment

by:RiverGuy
ID: 8121972
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
 

Author Comment

by:Scarfish
ID: 8122995
What does the SQL statement looks like??

CREATE TABLE Bla
(ID ??? NOT NULL)

what do i fill in for the question marks??
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Accepted Solution

by:
ocjared earned 180 total points
ID: 8132916
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
 

Author Comment

by:Scarfish
ID: 8135275
I know sql, but i didn't know how to set a column to autonumber.
0
 
LVL 3

Expert Comment

by:RiverGuy
ID: 8137348
The word Identity means autonumber in SQL.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question