How to create an AutoNumber field with a SQL statement?



I need to upgrade a MS Access database (Version 2002) with a script
only, i.e., via SQL statement, not via Access GUI, and I'm having
trouble defining an AutoNumber field. I got an exception error when
running the follwoing (in a C++ program using ADO):

......
cmdStr = "CREATE TABLE mytab "
"([Id] AutoNumber, "
"[Desc] TEXT(50), "
"CONSTRAINT [PK_MYTAB] PRIMARY KEY ([Id])); ";
pConn->Execute(cmdStr, NULL, adExecuteNoRecords);

When I changed the "Id" column data type to "integer", the program
updated the Access database successfully. However, the "id" field now
becomes a regular integer field. How do I make it an AutoNumber field
with a SQL statement?

Thanks.

.



Relevant Pages

  • Re: How To Return Record Number From AddNew
    ... After adding a record to an Access Database (programmatically using ... the autonumber field should cntain the ... newly allocated value after the update resulting from the AddNew occurs. ... This email account is my spam trap so I ...
    (microsoft.public.data.ado)
  • Re: How to create an AutoNumber field with a SQL statement?
    ... only, i.e., via SQL statement, not via Access GUI, and I'm having ... trouble defining an AutoNumber field. ... I did find that you can do it with the CreateTable method of the DAO.Database object with an Attribute parameter. ...
    (comp.databases.ms-access)
  • Re: Combo Box "Not In List" VBA code to Add item to table
    ... Bob Alston wrote: ... I believe the reason your encountering the error is that you are trying to insert a value into an autonumber field in your SQL statement. ...
    (comp.databases.ms-access)
  • Re: how do you update a java.sql.date type in an ms access database
    ... > when i update a row in an access database the date field ... DateTime data type in Access/Jet is more like a java.sql.Timestamp. ... Well, partly, but you're not using the date AS a date in the SQL statement, ... but as a String. ...
    (comp.lang.java.help)
  • Re: referring previous record of recordset from within sql statement
    ... If you add an autonumber field to your table (call it doc_id and make it the ... Then use this sql statement to retrieve your records: ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.db)