problem using MAX() SQL function

Results 1 to 5 of 5

Thread: problem using MAX() SQL function

  1. #1
    John Cross Guest

    Default problem using MAX() SQL function

    This is my SQL query:<BR>getID = "SELECT MAX(USER_ID) FROM DB.USERS"<BR><BR>But when I use this code...<BR>Response.Write(lastAttOrigID("USER_ID") )<BR> display the value returned by the query, I get this error:<BR><BR>"Item cannot be found in the collection corresponding to the requested name or ordinal."<BR><BR>How do I reference the value that is returned by my query, or is this a limitation of ASP (i.e., it can&#039;t read &#039;complex&#039; RecordSet values)?<BR>

  2. #2
    Join Date
    Dec 1969

    Default There is no such limitation

    This error means your field name is probably not USER_ID and something else, check the field name.

  3. #3
    Jeremy_D Guest

    Default RE: problem using MAX() SQL function

    You are trying to read a field called "USER_ID", but there&#039;s no such field in your result-set - you are not selecting "USER_ID", you are selecting "Max(USER_ID)". Try it like this:<BR><BR>getID = "SELECT Max(USER_ID) AS Max_ID FROM DB.USERS"<BR>[...]<BR>Response.Write(lastAttOrigID("Max_ID"))<BR><BR >Jeremy_D<BR><BR>

  4. #4
    Join Date
    Dec 1969

    Default Exactly, how could I miss it ? oh well anyway.


  5. #5
    John Cross Guest

    Default Thanks for the solution Jeremy

    Using the "AS whatever_ID" function works. Also, turns out I can call "Max(User_ID)" also and it works.<BR><BR>Your help was appreciated!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts