Autonumber

bloukewer

Well-known member
Joined
Jul 2, 2004
Messages
88
Programming Experience
3-5
I'm having one helluva struggle trying to figure out how to insert a new record into a table with an autonumber field. If someone could just copy-and-paste an example of a oledbcommand.commandtext that does this it would be much appreciated. I know I saw it somewhere on this discussions but alas, I can't find it.

Also, a question. Is it possible to put two Insert-statements into one command object ?
 

mzim

Well-known member
Joined
Jun 3, 2004
Messages
187
Location
Other side of the rock
Programming Experience
1-3
Also, a question. Is it possible to put two Insert-statements into one command object ?
yes
VB.NET:
 "select * from customers; select * from authors"
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
To insert a new record into a table with an autonumber field, you create a standard INSERT statement and leave out the field that has the type autonumber (include all fields except the autonumber field). The database will automaically add the next number to the autonumber field within the record.

Using two INSERT statements is similar to what MZIM has shown with the SELECT statements; use a semicolon between the two INSERT statements.
 
Last edited:

bloukewer

Well-known member
Joined
Jul 2, 2004
Messages
88
Programming Experience
3-5
Thank you very much.

Reality is an illusion - But illusions are also a reality...
 
Top Bottom