Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

last insert id

Status
Not open for further replies.

s4dadmin

Programmer
Apr 27, 2003
107
US
I am having a problem with using the sql statement
select last_insert_id();
Here is my code

Set rs2 = DbConn.Execute( "SELECT last_insert_id();" )
topicnum = rs2(0)
rs2.Close
Set rs2 = Nothing

Running this code only returns an id of 0 which causes duplicate id errors.
I am running the max debug server on localhost, w2k.
Not sure what could be wrong because it works fine on my host server. Should I change to another service? Can anyone help?
 
last_insert_id() returns the auto_increment ID of the record that was last inserted on your current connection.

If you have not inserted a record through your current connection, or if the table did not have an auto_increment column, last_insert_id() will return zero.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Of course i had the insert statement just before the last insert id statement but my mistake was not having the auto increment column, it was listed as just integer, Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top