Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Inserting record with Microsoft Access

Reply
Thread Tools

Inserting record with Microsoft Access

 
 
jeffhg582003
Guest
Posts: n/a
 
      02-09-2006
Hi,

I am developing a python script which add records to
a microsoft access tables. All my tables have autogenerated number
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.

Thanks,
Jeff



 
Reply With Quote
 
 
 
 
daftspaniel@gmail.com
Guest
Posts: n/a
 
      02-09-2006
I can't remember the detail right now but look at SELECT @@IDENTITY.

Cheers,
Davy M

 
Reply With Quote
 
 
 
 
Kelly
Guest
Posts: n/a
 
      02-09-2006
"jeffhg582003" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> 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)

 
Reply With Quote
 
Tim Roberts
Guest
Posts: n/a
 
      02-11-2006
"jeffhg582003" <(E-Mail Removed)> wrote:
>
>I am developing a python script which add records to
>a microsoft access tables. All my tables have autogenerated number
>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.


http://support.microsoft.com/kb/221931/EN-US/

What tool are you using? With ADODB recordsets, you can fetch the
"absolutePosition" property, save it, do a Requery to update the recordset,
then set absolutePosition to the value you saved. Now, you can read the
fields of your new record, including the autonumber.
--
- Tim Roberts, http://www.velocityreviews.com/forums/(E-Mail Removed)
Providenza & Boekelheide, Inc.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
Re: Inserting record with Microsoft Access Steve Holden Python 2 02-12-2006 02:40 AM
Re: Inserting record with Microsoft Access Albert Leibbrandt Python 1 02-09-2006 05:39 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments