Getting auto-generated PK value back
I was told in another post that after inserting a row with an autogenerated PK, I can get the PK value back using LAST_INSERT_ID() or mysql_insert_id().
Is the way to do this:
cmd.CommandText = "insert into Schedule (sTitle, sDescription) values ('my sched', 'all about it'); LAST_INSERT_ID()";
object rtn = cmd.ExecuteScalar();
return (long)(decimal)rtn;
thanks - dave
ps - I am asking instead of trying because I am still waiting on the DBA to convert our schema from SqlServer to MySql (is there a tool that does this other than ErWin? Something not a fortune so I can get it for myself and not have to wait?).
Subject
Written By
Posted
Getting auto-generated PK value back
November 12, 2006 04:39PM
November 12, 2006 05:08PM
November 28, 2006 05:11AM
November 28, 2006 08:46AM
November 28, 2006 02:36PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.