Re: asp.net sqldatasource last_insert_id
Posted by: Hearth Stone
Date: December 08, 2011 07:58PM

After spending nearly a whole day trying to figure this out, i have stumbled across a solution. All the articles I found on the web rely on using stored procedures to get the output parameters working (which is not an option in my circumstance).

However, there are some nice .net classes available to add to your solution as references: MySql.Data.MySqlClient
Using this will allow you to convert the datasource command object to a MySqlCommand object, which has the LastInsertedId property.

eg: in the DataSource_Inserted event, write
int newID = ((MySqlCommand)e.Command).LastInsertedId;

Options: ReplyQuote


Subject
Written By
Posted
Re: asp.net sqldatasource last_insert_id
December 08, 2011 07:58PM


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.