SqlDataAdapter 获取标识
我正在执行以下操作来获取插入行的标识:
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();
}
}
有没有办法自动获取标识?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论