CSDN博客

img kingapex1

读取刚刚插入纪录的id

发表于2004/10/8 9:22:00  1232人阅读

sql = "SET NOCOUNT ON;INSERT INTO docTmpl (Title) VALUES('" & Replace(strTitle,"'","''") & "');SELECT @@IDENTITY;SET NOCOUNT OFF"
Set rs = cn.Execute(sql)
If rs.EOF Then Response.Write "没有得到返回记录ID,操作可能无法继续进行。" : Response.End
strID = rs(0)



'获得刚插入记录的id号
'启动事务
Conn.BeginTrans
Conn.Execute("Insertinto....")
'查询新加记录ID号的SQL语句
SetRS=Conn.Execute("SELECT@@IDENTITYASGuideID")
ID=RS("GuideID")
'提交事务
Conn.CommitTrans


myRs.Open strSql,myCn1,2,3
If myRs.EOF Then
 myRs.AddNew
 myRs("A_Name") = strUserName
 myRs("A_LoginName") = strLoginName
 myRs("A_Domain") = LoginUserDomain
 myRs("A_email") = email
 myrs("A_IsEnabled") = 1
 myrs("A_Password") = EncryptPwd
 myRs.Update
 bookmark = myRs.absolutePosition  ' First, store the location of you cursor
 myRs.Requery                      ' Next, update your recordset with the data from the database

 'after the requery, the absolutePosition is the first record of the recordset
 newUserGuid = myRs("id")
End If

阅读全文
0 0

相关文章推荐

img
取 消
img