We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

ASP max id

BR
BR asked
on
Medium Priority
513 Views
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 & "')"
rs.open sqlcumle, con, 1, 3	
 
sqlcumle2= "Select MAX(id) FROM tablename"
con.execute sqlcumle2
id2=rs(id)

Open in new window

Comment
Watch Question

Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer
CERTIFIED EXPERT

Commented:
try:

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)
id2=rs(0)

...
BRDigital Marketing

Author

Commented:
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.
BRDigital Marketing

Author

Commented:
Error mesage is about line 360 which is id2=rs(0)
thank you
Software Tead Lead / Business Analyst / System Analyst / Data Engineer
CERTIFIED EXPERT
Commented:
emm, try:

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


?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.