Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert from ASP to access (auto-increment field)

Posted on 2006-06-13
3
Medium Priority
?
342 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 500 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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 …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

719 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