Solved

Insert from ASP to access (auto-increment field)

Posted on 2006-06-13
3
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

734 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