Solved

Insert from ASP to access (auto-increment field)

Posted on 2006-06-13
3
327 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now