有没有办法在ADODB中执行SELECT SCOPE_IDENTITY()? [英] is there a way to do SELECT SCOPE_IDENTITY() in ADODB?

查看:95
本文介绍了有没有办法在ADODB中执行SELECT SCOPE_IDENTITY()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

结尾

这是我添加记录的方式。是可以做些喜欢的事情吗?

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
     SCOPE_IDENTITY()  <----------------
    .Update ' stores the new record


End With


推荐答案

执行Update命令后,标识将放置在记录集中的相应字段中。

After you have executed the Update command, the identity will be placed in the corresponding field in the recordset. You can read it from there.

示例:

id = .Fields("id")

这篇关于有没有办法在ADODB中执行SELECT SCOPE_IDENTITY()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆