bannerbannerbannerbannerbanner
Jova wiki   tid   Login/Logout

RSS

Navigation





Quick Search
»
Advanced Search »

PoweredBy

asp.net sqldatasource last_insert_id

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;

Hearth_Stone

Jova wiki is © Jovall