"jeffhg582003" <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:

> fields. I am trying to capture the number generated from the insert 
but
> I am not exactly sure how to do that after an insert.

Other folks have pointed you to "select @@identity" but I thought I 
should mention that if you use ADO with the AddNew method then 
autonumbers are magically retrieved. Something like this should work:

rs.AddNew()
rs.Fields("somefield").Value= "Blah"
rs.Update()
print "Autonumber is", rs.Fields("TheAutonumberField").Value

This didn't always work so ADO and the MDB can't be ancient versions.

SQL Server will also do this but the recordset must be opened with:

rs.CursorLocation= constants.adUseServer
rs.Open("Tablename", conn, constants.adOpenKeyset,
        constants.adLockOptimistic)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to