NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
.NET Data Types
.NET E-mail
.NET Events
.NET Functions
.NET Object Programming
.NET System.Configuration
.NET System.Diagnostics
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Authentication
ASP.NET Controls
ASP.NET Data Access
ASP.NET Features
ASP.NET Master Pages
ASP.NET Page Events
ASP.NET Security
ASP.NET ViewState
Atom
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
Exporting Data
HTML Tips
IIS
Object-Oriented Programming
RSS
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax
XML

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

Adding Records to Tables with AutoIncrement Fields

Written by Eric Smith, Northstar Computer Systems LLC

Ever have a table that has an autoincrement (AutoNumber in Access, for instance) field and not sure how to add a record to the field? If you try to put a value into the field, you'll get an error. The solution? Don't put a value into it. If you're using an ADO Recordset inserting into a table, you can store the rest of the fields like normal and then do an Update. The database will add your autoincremented number, and you'll be able to get the value immediately after you call the Update method on the ADO Recordset.

The same thing goes for SQL statements. Don't list the automatically supplied field in the list of fields you supply in the INSERT statement and the database will automatically plug the automatic value in.

Keywords: [ Active Data Objects ]

Publication Date: 2/10/2001, Last Update: 2/12/2010