Return ID on INSERT?(在 INSERT 上返回 ID?)
问题描述
我有一个 INSERT 查询,我希望数据库返回我刚刚插入的行的 ID.
I have an INSERT query and I want the DB to return the ID of the row I just inserted.
我目前有这个,我不确定接下来我需要做什么......
I currently have this, I'm not sure what I need to do next...
推荐答案
你只需要在params集合中添加@ID,然后像这样检索它,
You just need to add @ID to the params collection and then retrieve it like this,
或者,如果您更喜欢这种语法:
Or, if you prefer this syntax:
这篇关于在 INSERT 上返回 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!