[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP max id

Posted on 2009-02-10
4
Medium Priority
?
493 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

0
Comment
Question by:Braveheartli
  • 2
  • 2
4 Comments
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 23599671
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)

...
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 23599704
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.
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 23599719
Error mesage is about line 360 which is id2=rs(0)
thank you
0
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 23599915
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


?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

834 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