[thelist] asp/vbscript array problems

Ken Schaefer Ken at adOpenStatic.com
Tue May 3 08:45:24 CDT 2005


<%
strSQL = "INSERT ...."
objConn.Execute strSQL

strSQL = "SELECT @@IDENTITY"
Set objRS = objConn.Execute strSQL

intID = objRS.Fields(0).Value

Set objRS = Nothing
Set objConn = Nothing
%>

SELECT @@IDENTITY returns the last autonumber created on the current
connection, so make sure you reuse the same ADO Connection object.

Cheers
Ken

--
www.adOpenStatic.com/cs/blogs/ken/ 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of Pringle, Ron
: Subject: RE: [thelist] asp/vbscript array problems
: 
: 
: > <snip>
: > :
: > : Basically, its an events calendar that can have multiple
: > dates assigned to
: > : an event. For each date for a particular event there can be
: > Agendas and
: > : Minutes assigned to it. Because there are multiple dates
: > for events, I
: > : have
: > : to grab the last dateID from the eventDates table so that I
: > can increment
: > : it
: > : by 1 for each event date and write it to the committeeDocs
: > table to create
: > : the relation between the two tables.
: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: >
: > Warning, Warning, Warning!
: >
: > Why don't you just use an autonumber field (assuming Access)
: > and have the
: > DBMS take care of generating the IDs for you? You can use
: > SELECT @@IDENTITY
: > to get newly generated IDs if required.
: >
: > Cheers
: > Ken
: 
: Ken-
: 
: Actually I do use the autonumber field to generate the dateID in the
: eventDates table. But I have to know what the number is going to be so
: that
: I can create the relationship to it in the related committeeDocs table.
: I'll
: check out the SELECT @@IDENTITY though, thanks!
: 
: Ron


More information about the thelist mailing list