I'd rather not make a call to the database to query @@IDENTITY. Is there some way to get the identit开发者_运维技巧y value for what was just inserted through code?
Found a solution by adding an OnInserted event to my LinqDataSource that my listview was using. See below:
protected void lds_Personnel_OnInserted(object sender, LinqDataSourceStatusEventArgs e)
{
int id= ((Personnel)e.Result).IdentityNameHere;
.
.
.
}
Hope it's helpful to someone.
Try using SCOPE_IDENTITY()
instead.
精彩评论