Unique ID's

Results 1 to 2 of 2

Thread: Unique ID's

  1. #1
    Paul Lonsdale Guest

    Default Unique ID's

    Hi,<BR><BR>When inserting into a table (Access DB using ADO), I need to immediatly read back the value of an auto incrementing &#039ID&#039 column. There are two ways I can think of doing it, one is to read the entire table into a recordset and use the &#039AddNew&#039 method and uppon updating the RS, I could use &#039MoveLast&#039 and read the value of the &#039ID&#039 column. The 2nd way is to insert the record along with a colum containing a unique ID that I know about then &#039SELECT&#039 on that unique ID to get the auto-num field value. The first way is no good as I don&#039t want to have to load the entire table whenever I need to add a row, and the second is a bit dodgy as I would normally use a GUID (Globally Unique ID) in my VB apps, but how do I generate a GUID using ASP/JScript/VBScript? I thought of using the &#039Session.SessionID&#039 as my unique ID, but if IIS is restarted on the server, I could possibly have conflicts...<BR><BR>Any ideas?<BR><BR>Please mail me at &#039plonsdale@racalrec.co.uk&#039 or reply to this post and my gratidute will be immense...<BR><BR>Thanx,<BR><BR>Paul Lonsdale.

  2. #2
    Join Date
    Dec 1969

    Default RE: Unique ID's

    I recently ran across that problem with Access. There&#039s no way to retrieve the value of the AUTONUMBER once you insert your data (and be sure it&#039s 100% accurate).<BR><BR>What I did is create a unique ID of sorts within my ASP code. <BR><BR>Dim uniqueid<BR>randomize()<BR>uniqueid = int(rnd*100000000000000)<BR><BR>While there is a *small* chance of a duplicate number someday, odds are that if you&#039re using Access, the particular application is not that large. You could always add random letters to the number as well.<BR><BR>I don&#039t know if there is a way to generate a "real" GUID (like SQL Server lets you do) with VBScript/JS. I doubt it. <BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts