File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Inserting Auto Number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Inserting Auto Number " Watch "Inserting Auto Number " New topic

Inserting Auto Number

Sri Gnana
Ranch Hand

Joined: Apr 29, 2004
Posts: 166
Currently I'm working with JSP and MSAccess , i wanna insert auto number from the jsp page, can any one give me the idea how can i do it, if you have any site reference pls give me the link,

Thanks & Regards
Sri Gnana
Everythings Programmed!...
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
You can't insert an explicit number since it is an AutoNumber field. To insert a new row, either leave the autonumber field out of the insert clause OR set it to a value of 0. In either case, Access will automatically insert the next number.

For example, if you have table "table1" with columns: (id autonumber) and (field1 char(20)), then here are the 2 inserts you can choose from:
1. insert into table1 (field1) values ("some text") // id column left out
2. insert into table1 (id, field1) values (0, "some text") // id set to 0

Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Sri Gnana
Ranch Hand

Joined: Apr 29, 2004
Posts: 166
Thanks Blake
Don't get me started about those stupid light bulbs.
subject: Inserting Auto Number
It's not a secret anymore!