开发者

SqlDataAdapter Get Identity

I'm doing the following to get the identity of an inserted row:

SqlConnection con = new SqlConnetion("connectiontxc");
SqlDataAdapter adap = new SqlDataAdapter("Select * from Student");

void adap开发者_运维问答_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e)
{
    if (e.StatementType == StatementType.Insert)
    {
        e.Row["Id"] = (new System.Data.SqlClient.SqlCommand("Select @@Identity")).ExecuteScalar();          
    }
}

Is there a way to get the identity automatically?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜