Click here to Skip to main content
15,901,205 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to add a new record and get an autonumber field value Pin
albean15-Aug-02 18:46
albean15-Aug-02 18:46 
GeneralRe: How to add a new record and get an autonumber field value Pin
Luis Alonso Ramos15-Aug-02 22:28
Luis Alonso Ramos15-Aug-02 22:28 
GeneralRe: How to add a new record and get an autonumber field value Pin
James T. Johnson16-Aug-02 1:15
James T. Johnson16-Aug-02 1:15 
GeneralRe: How to add a new record and get an autonumber field value Pin
Nnamdi Onyeyiri16-Aug-02 1:51
Nnamdi Onyeyiri16-Aug-02 1:51 
GeneralRe: How to add a new record and get an autonumber field value Pin
James T. Johnson16-Aug-02 1:54
James T. Johnson16-Aug-02 1:54 
GeneralRe: How to add a new record and get an autonumber field value Pin
Luis Alonso Ramos16-Aug-02 6:00
Luis Alonso Ramos16-Aug-02 6:00 
GeneralRe: How to add a new record and get an autonumber field value Pin
Luis Alonso Ramos16-Aug-02 6:17
Luis Alonso Ramos16-Aug-02 6:17 
GeneralRe: How to add a new record and get an autonumber field value Pin
James T. Johnson16-Aug-02 8:20
James T. Johnson16-Aug-02 8:20 
On the OleDbCommand object, use the ExecuteScalar method; it will return the first column of the first row, in this case it will return the value of @@IDENTITY which is the first (and only) column of the first (and only) row.

OleDbCommand cmd = new OleDbCommand("SELECT @@IDENTITY", myConnection);
 
conn.Open();
 
int identity = (int) cmd.ExecuteScalar();
 
conn.Close();


James
"And we are all men; apart from the females." - Colin Davies
GeneralRe: How to add a new record and get an autonumber field value Pin
Luis Alonso Ramos17-Aug-02 8:20
Luis Alonso Ramos17-Aug-02 8:20 
GeneralControls not appearing correctly Pin
Luis Alonso Ramos15-Aug-02 17:23
Luis Alonso Ramos15-Aug-02 17:23 
GeneralRe: Controls not appearing correctly Pin
TigerNinja_15-Aug-02 18:57
TigerNinja_15-Aug-02 18:57 
GeneralRe: Controls not appearing correctly Pin
Luis Alonso Ramos15-Aug-02 22:31
Luis Alonso Ramos15-Aug-02 22:31 
GeneralNice Link :) Pin
leppie15-Aug-02 15:20
leppie15-Aug-02 15:20 
GeneralRe: Nice Link :) Pin
David Stone15-Aug-02 19:11
sitebuilderDavid Stone15-Aug-02 19:11 
GeneralRe: Nice Link :) Pin
Nnamdi Onyeyiri16-Aug-02 0:49
Nnamdi Onyeyiri16-Aug-02 0:49 
GeneralPassing null to extern functions Pin
leppie15-Aug-02 15:14
leppie15-Aug-02 15:14 
GeneralRe: Passing null to extern functions Pin
albean15-Aug-02 18:02
albean15-Aug-02 18:02 
GeneralRe: Passing null to extern functions Pin
leppie16-Aug-02 0:27
leppie16-Aug-02 0:27 
GeneralRe: Passing null to extern functions Pin
Richard Deeming16-Aug-02 1:30
mveRichard Deeming16-Aug-02 1:30 
GeneralRe: Passing null to extern functions Pin
leppie16-Aug-02 1:38
leppie16-Aug-02 1:38 
GeneralProblem solved :) Pin
leppie16-Aug-02 14:09
leppie16-Aug-02 14:09 
GeneralCasting Repost Pin
leppie15-Aug-02 6:10
leppie15-Aug-02 6:10 
GeneralRe: Casting Repost Pin
Nick Parker15-Aug-02 10:44
protectorNick Parker15-Aug-02 10:44 
GeneralRe: Casting Repost Pin
leppie15-Aug-02 13:54
leppie15-Aug-02 13:54 
GeneralRe: Casting Repost Pin
Eric Gunnerson (msft)16-Aug-02 7:06
Eric Gunnerson (msft)16-Aug-02 7:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.