Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate primary key in database from adding new records 1

Status
Not open for further replies.

Beng79

Technical User
Jan 5, 2006
48
HK
Good day to all,

After users enter data into textboxes and the data are captured into the database as new records in a table, is there any way to auto generate a primary key in the database from ASP scripts?

Note: Primary key is not entered by users but have to be auto generated.

Must the data type for primary key field in the MS Access database table be "AutoNumber" so the above can happen?

Thanks
 
Must the data type for primary key field in the MS Access database table be "AutoNumber" so the above can happen?

Yes and in the future please post MS Access questions in the MS Access forums. Thanks...



General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
Beng79 said:
Must the data type for primary key field in the MS Access database table be "AutoNumber" so the above can happen?

Yes. Make your field the Autonumber and user doesnt need to enter it on the form...once a new record is added, the auto number is generated automatically...

-DNG
 
is there any other solution from ASP script if I do not want the data type to be "AutoNumber"?

This is because the primary key for that table will not be unique since "AutoNumber" does not accept characters and I still have other tables with primary key need to be auto generated as well.

Sorry if I reply in this forum, as I am working on ASP scripts.
 
This is because the primary key for that table will not be unique since "AutoNumber"

That is incorrect. The autonumber type will be unique. using teh database functionality is the correct way to do this also. Even if you want to create your own primary key in the tables it should still be done with a function built into the table and not via your ASP's.

If you still question how this process should be done I would post the question in the access forum. I'm sure they will give you a ear full of primary key generations and proper methods :)





General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
yes, thank you. I appreciate it very much. = )
 
not a problem. hope you find what you're looking for



General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top