熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

得到剛剛插入的記錄的自動編號值一例

2013-11-13 10:03:15  來源: .NET編程 
對於access和Sql server 數據庫下面方法可以得到剛剛插入記錄的自動編號值

得到剛剛插入的記錄的自動編號值


dim connrs
set conn=ServerCreateObject(ADODBConnection)
connOpen Provider=MicrosoftJetOLEDB;Jet OLEDB:Database Password=;Data Source= & ServerMapPath(windowsmdb)
set rs=ServerCreateObject(ADODBRecordset)

sql=select * from [table] where ID is null 自動編號字段為id
rsopen sqlconn
rsaddnew
rs(Name) = Requestform(Name)
rs(Name) = Requestform(Name)
rsupdate
responsewrite ID值<strong color:red;> & rs(ID) & </strong> 得剛剛插入記錄的自動編號的值
rsclose
set rs = nothing
connclose
set conn = nothing
From:http://tw.wingwit.com/Article/program/net/201311/12404.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.