[thelist] Pausing ASP script when no acces to SQL server -SOLVED

Ken Schaefer Ken at adOpenStatic.com
Wed Aug 16 18:10:05 CDT 2006


Yes, I can confirm it:
http://www.adopenstatic.com/experiments/fastestautonumber.asp

You need to be using OLEDB Provider, not ODBC Driver.
Alternatively, use a recordset.

The way you were doing it before (with a pause, and SELECT MAX()) is
completely *unsuitable* if you have multiple users on your website. You'll
have different users getting the wrong IDs (e.g. I insert a record. User2
inserts a record. After one second the Select Max() is done - both users get
User2's ID). If you only have a single user, it'll work, but trying to
"pause" a webpage isn't a good idea. Offload that type of work to a
background service.

Cheers
Ken

--
My IIS Blog: www.adOpenStatic.com/cs/blogs/ken
Tech.Ed Sydney: learn all about IIS 7.0 - See you there!


: -----Original Message-----
: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of Chris Dempsey
: Sent: Thursday, 17 August 2006 1:23 AM
: To: thelist at lists.evolt.org
: Subject: Re: [thelist] Pausing ASP script when no acces to SQL server -
: SOLVED
: 
: Couldn't get @@IDENTITY to work on the Access Database - it keeps returning
: value of '0' as the new ID - although I did find the following which
: provided an alternative:
: 
: http://support.microsoft.com/default.aspx/kb/221931
: 
: Can anyone confirm that as Jason and
: http://www.drdev.net/article06Print.htm
: say, that @@Identity can be used on Access?  All I got were values of '0'
: and no errors.
: 
: Thanks anyway Jason - your first link led me to find the link to MS KB
: Article which worked for me.
: 
: Chris.
: 
: -----Original Message-----
: From: thelist-bounces at lists.evolt.org
: [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Chris Dempsey
: Sent: 16 August 2006 15:30
: To: thelist at lists.evolt.org
: Subject: Re: [thelist] Pausing ASP script when no acces to SQL server
: 
: > Why not use @@IDENTITY
: I had seen this come up before but the same article also said it was only
: suitable for SQL Server databases??
: 
: Will read up on the MS Knowledgebase article you linked.  Thank you.
: 
: Chris.
: 
: -----Original Message-----
: From: thelist-bounces at lists.evolt.org
: [mailto:thelist-bounces at lists.evolt.org] On Behalf Of jason.handby
: Sent: 16 August 2006 15:10
: To: thelist at lists.evolt.org
: Subject: Re: [thelist] Pausing ASP script when no acces to SQL server
: 
: Hi Chris,
: 
: 
: > I require to pause an ASP script for around 1 second after
: > doing a database insert so I can grab the unique ID from the
: > new record in an access database
: > using: SELECT MAX (itemID) AS maxID FROM tblItems"
: >
: > If I don't pause the script I get the previous maxID.
: 
: 
: You absolutely don't want to do this!!!
: 
: Why not use @@IDENTITY to get the unique ID of the last inserted record?
: 
:   http://support.microsoft.com/kb/232144/EN-US/
: 
: 
: 
: Jason




More information about the thelist mailing list