#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    24
    Rep Power
    0

    Pulling Auto-number


    Guys,

    Is there a way to pull the auto-number of a row entered into a database? IE, if I create an order, automatically pull the order_no from the order_table so that I can insert it into an order_detail table. There has to be a better way then selecting max order_id because that might not be the most current order?

    I know there is a buiilt in function in php what about asp?

    THanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    NJ
    Posts
    428
    Rep Power
    17
    PHP Code:
    set con server.createObject("ADODB.CONNECTION"
    con.open DATASOURCE
    sql 
    "insert into tbl values(val1); " 
    con.execute sql 

    objAutoNum 
    con.execute("Select @@Identity from tbl")
    strAutoNum objAutoNum(0)

    con.close
    set con 
    nothing 
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    24
    Rep Power
    0
    Originally posted by imbrokn
    PHP Code:
    set con server.createObject("ADODB.CONNECTION"
    con.open DATASOURCE
    sql 
    "insert into tbl values(val1); " 
    con.execute sql 

    objAutoNum 
    con.execute("Select @@Identity from tbl")
    strAutoNum objAutoNum(0)

    con.close
    set con 
    nothing 

    thanks that solved the problem

IMN logo majestic logo threadwatch logo seochat tools logo