If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Problem with MAX()

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-28-02, 14:50
Shurik Shurik is offline
Registered User
 
Join Date: Mar 2002
Posts: 14
Problem with MAX()

I need to get the Autonumber of the newly inserted data. I am using second SQL to get the max(Autonumber)
SQL="SELECT (MAX(T_ID) as ID from TradeTbl)"

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQL, MyConn, 3

Reponse.write returns me empty data (not null).

What is going on? Do I need to set up a new connection (tried that) or what can I do?
I would really appreciate your help
Reply With Quote
  #2 (permalink)  
Old 08-28-02, 15:11
Shurik Shurik is offline
Registered User
 
Join Date: Mar 2002
Posts: 14
I know I could use rs.addnew and rs.update to get the Autonumber.
However, I am using a huge (and I mean it, HUGE SQL statement with if else statements inside), and I wouldn't want to build a whole new procedure using addnew and update. :-(
Help!!!
Reply With Quote
  #3 (permalink)  
Old 08-28-02, 15:59
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Which database are you using ?
Reply With Quote
  #4 (permalink)  
Old 08-28-02, 16:17
Shurik Shurik is offline
Registered User
 
Join Date: Mar 2002
Posts: 14
MS ACCESS
the addnew/update is working
but i still want to know how to solve the prob with plain sql statements
Reply With Quote
  #5 (permalink)  
Old 08-28-02, 17:10
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Run the "select @@identity" statement after the record has been inserted. You can then reference it using rs(0).
Reply With Quote
  #6 (permalink)  
Old 08-29-02, 11:19
Shurik Shurik is offline
Registered User
 
Join Date: Mar 2002
Posts: 14
Thumbs up

Quote:
Originally posted by rnealejr
Run the "select @@identity" statement after the record has been inserted. You can then reference it using rs(0).
Dear rnealejr!
Thank you so much for the help!!! I think you DO deserve that fifth star! "Select @@Identity" worked!
I will come back again if I have some other issues.
Thank you
Reply With Quote
  #7 (permalink)  
Old 08-29-02, 11:19
Shurik Shurik is offline
Registered User
 
Join Date: Mar 2002
Posts: 14
Thumbs up

Quote:
Originally posted by rnealejr
Run the "select @@identity" statement after the record has been inserted. You can then reference it using rs(0).
Dear rnealejr!
Thank you so much for the help!!! I think you DO deserve that fifth star! "Select @@Identity" worked!
I will come back again if I have some other issues.
Thank you
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On