我这样做:sql server:我如何获取插入的最后一条记录?
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("datapath") = dpath
.Fields("analysistime") = atime
.Fields("reporttime") = rtime
.Fields("lastcalib") = lcalib
.Fields("analystname") = aname
.Fields("reportname") = rname
.Fields("batchstate") = bstate
.Fields("instrument") = instrument
.Update ' stores the new record
End With
' get the last id
Set rs = cn.Execute("SELECT SCOPE_IDENTITY()", , adCmdText)
,这是不正常。它返回NULL
可能重复[scope_identity()question](http://stackoverflow.com/questions/3526851/scope-identity-question) – 2010-08-19 23:11:32