Solved

Insert from ASP to access (auto-increment field)

Posted on 2006-06-13
3
333 Views
Last Modified: 2012-08-13
Hello,

I would like to be able to insert a record, from ASP into an MS access database.
I have sucessfully created the database connection, and am able to pull records by doing SELECT statements, however I am running into a roadblock when i get to inserting because
one of the columns is an auto-incrementing field type in the database. What's the proper syntax to insert a line while leaving the field to be auto-incremented (it cannot be null, so I must send something in that column field). Something short of cycling through the table till the last entry and adding +1 to the last column value. Is there a specific syntax for this field type to trigger the auto-increment on the back end in the database?
0
Comment
Question by:system
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 125 total points
ID: 16897294
If the field is set up as an autonumbering field, you shouldn't need to pass anything in to access for that field.  This syntax works for me using asp.net/sql server.  I would think that It should work with an access back-end as well:

 strInsert = "INSERT INTO tblPersonnel (Field2,Field3,Field4) Values('" & me.txtField2.text & "','" & me.txtField3.text & "','" & me.txtField4.text & "')"

(Field1, an autonumbering field is left out completely but automatically increments when the rest of the line is inserted)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

856 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