how to get the new identity ID just after insert a new row?

Q

Quentin Huo

Hi:

I have a table which key is an identity integer ID named "readerID", so the
readerID is created by system after I insert the new record. I use the
following code to insert a new record:

strng sql = "INSERT ......";

OleDbConnection conn = new OleDbConnection();


conn.ConnectionString = Session["oleconn"].ToString();

conn.Open();


OleDbCommand cmd = new OleDbCommand(sql,conn);

int nNoAdded = cmd.ExecuteNonQuery();



I need to retrive the ID just after insert a new record, how can I do this?
In ASP, I don't need to use the query again. But I don't know how to do this
in ASP.NET.

Thanks

Q.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top