当前位置: 首页 > 图文教程 > 网络编程 > ASP > 技巧:得到刚刚插入的记录的自动编号值一例

ASP
ASP编程中15个非常有用的例子 (二)
ASP与JSP的比较(一)
ASP与JSP的比较(二)
ASP中五种连接数据库的方法
从ASP调用SQL中的图像
用排序串字段实现树状结构(例程:连接字串)
用排序串字段实现树状结构(例程:删除贴子)
用排序串字段实现树状结构(例程:回复表单)
用排序串字段实现树状结构(例程:显示贴子内容)
用排序串字段实现树状结构(例程:显示树)
用排序串字段实现树状结构(存储过程)
用排序串字段实现树状结构(库结构)
用排序串字段实现树状结构(原理)
remote script文档(转载自微软)(一)
remote script文档(转载自微软)(二)
remote script文档(转载自微软)(三)
remote script文档(转载自微软)(四)
remote script文档(转载自微软)(五)
remote script文档(转载自微软)(六)
remote script文档(转载自微软)(七)

ASP 中的 技巧:得到刚刚插入的记录的自动编号值一例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 143 ::
收藏到网摘: n/a

对于access和Sql server 数据库,下面方法可以得到刚刚插入记录的自动编号值。


'得到刚刚插入的记录的自动编号值

以下为引用的内容:

dim conn,rs
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=" & Server.MapPath("51windows.mdb")
set rs=Server.CreateObject("ADODB.Recordset")

sql="select * from [table] where ID is null" '自动编号字段为id
rs.open sql,conn,1,3
rs.addnew
rs("Name") = Request.form("Name")
rs("Name2") = Request.form("Name2")
rs.update

response.write "ID值:<strong style=""color:red;"">" & rs("ID") & "</strong>" '得刚刚插入记录的自动编号的值

rs.close
set rs = nothing
conn.close
set conn = nothing