permaculture playing cards
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
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
I agree. Here's the link:
subject: Inserting Auto Number
jQuery in Action, 3rd edition