ASP max id

Posted on 2009-02-10
Last Modified: 2012-05-06
I'd like to insert the data to my table, however I want to know which row I enter the data.
I mean I want to know the id of my last data entry.
how can I do that?
thank you in advance.

sqlcumle = "insert into tablename(Ad,Tel,Eposta,Sehir,Mark,Konu,Adres,Promosyon)  values('" & ad & "','" & tel & "','" & email & "','" & sehir & "','" & mark& "','" & konu & "','" & adres & "','" & promosyon & "')" sqlcumle, con, 1, 3	

sqlcumle2= "Select MAX(id) FROM tablename"

con.execute sqlcumle2


Open in new window

Question by:Braveheartli
    LVL 48

    Expert Comment

    by:Ryan Chong

    sqlcumle = "insert into tablename(Ad,Tel,Eposta,Sehir,Mark,Konu,Adres,Promosyon)  values('" & ad & "','" & tel & "','" & email & "','" & sehir & "','" & mark& "','" & konu & "','" & adres & "','" & promosyon & "')"
    con.execute sqlcumle
    sqlcumle2= "Select MAX(id) FROM tablename"
    set rs = con.execute(sqlcumle2)

    LVL 1

    Author Comment

    thank you for your promt reply.

    I tried. But it did not work.

    the Error message is:

     ADODB.Recordset error '800a0cc1'

    Item cannot be found in the collection corresponding to the requested name or ordinal.
    LVL 1

    Author Comment

    Error mesage is about line 360 which is id2=rs(0)
    thank you
    LVL 48

    Accepted Solution

    emm, try:

    sqlcumle2= "Select MAX(id) as maxid FROM tablename"
    set rs = con.execute(sqlcumle2)
    if rs.eof = false then
    end if


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now