Need help assigning id

Results 1 to 2 of 2

Thread: Need help assigning id

  1. #1
    Andis Guest

    Default Need help assigning id

    In my database, I need to assign an id number with the next consecutive id. I was trying dmax + 1 but it is not recognizing that. What is the ASP code to do this? I have a temp id field in access which is an autonumber, and I want the id field to mimic this but have "temp" + temp id value. HELP????

  2. #2
    Join Date
    Dec 1969

    Default my question, and your answer

    why in the world would you want 2 fields with identical values everytime?? i mean, if you already have this id set up as an autonumber, why would you want another column...oh well, i suppose i can just do this=) i&#039m going to use a code that i personally use (and wrote) to capture the id that you just it goes:<BR><BR>&#060;%<BR>set dbcn=Server.CreateObject("ADODB.Connection")<BR>db cn.Open "DSN=intranet"<BR>set dbrs=Server.CreateObject("ADODB.Recordset")<BR>dbr s.ActiveConnection=dbcn<BR>dbrs.Open "insert into customer (usertype) values (1)",,3,4<BR>dbrs.Open "select max(userid) as newid from customer",,3,4 <BR>id=dbrs.Fields("newid")<BR>&#039end of what i wrote (i actually go on to create a cookie)<BR>dbrs.Open "insert into customer (temp) values (" & id & ") where userid=" & id<BR>%&#062;<BR><BR>couple of things:<BR>1)userid is the autonumber field<BR>2)newid is an alias and is not a field<BR>3)usertype is a dummy field...not used for anything<BR>4)i think that about does it!! if you have any questions, feel free to ask!

Posting Permissions

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