bannerbannerbannerbannerbanner
Jova wiki   tid   Login/Logout

RSS

Navigation





Quick Search
»
Advanced Search »

PoweredBy

Page History: Använda LastInsertId

Compare Page Revisions

Compare revision to revision


List of revisions

« Older Revision - Back to Page History - Current Revision


Page Revision: 2019/09/05 13:59


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_CABB

Jova wiki is © Jovall