對於access和Sql server 數據庫
下面方法可以得到剛剛插入記錄的自動編號值
得到剛剛插入的記錄的自動編號值
dim conn
rs
set conn=Server
CreateObject(
ADODB
Connection
)
conn
Open
Provider=Microsoft
Jet
OLEDB
;Jet OLEDB:Database Password=;Data Source=
& Server
MapPath(
windows
mdb
)
set rs=Server
CreateObject(
ADODB
Recordset
)
sql=
select * from [table] where ID is null
自動編號字段為id
rs
open sql
conn
rs
addnew
rs(
Name
) = Request
form(
Name
)
rs(
Name
) = Request
form(
Name
)
rs
update
response
write
ID值
<strong color:red;
>
& rs(
ID
) &
</strong>
得剛剛插入記錄的自動編號的值
rs
close
set rs = nothing
conn
close
set conn = nothing
From:http://tw.wingwit.com/Article/program/net/201311/12404.html