建站常识

asp如何取得插入记录后最新ID的值?

发布时间 | 2015/4/15  点击 | 

ACCESS库可以这样书写:
set rs = server.createobject("adodb.recordset")
sql = "select * from news"
rs.addnew
rs("title") = "测试"
rs("content") = "内容"
rs.update
newid = rs("id")
rs.close

SQLSERVER用上面的方法不行,必须在UPDATE后多加一句,rs.movelast.
set rs = server.createobject("adodb.recordset")
sql = "select * from news"
rs.addnew
rs("title") = "测试"
rs("content") = "内容"
rs.update
rs.movelast
newid = rs("id")
rs.close

相关信息