SELECT Max() as 'newID' FROM ...

Results 1 to 3 of 3

Thread: SELECT Max() as 'newID' FROM ...

  1. #1
    Join Date
    Dec 1969

    Default SELECT Max() as 'newID' FROM ...

    I am having trouble getting an alias to return. I get an ordinal reference error when I try to retreive the result of the query. The query runs fine but I cant get the result. Any suggestions would be great.<BR><BR>SQLQuery = "SELECT Max(ID)+1 as &#039;NewID&#039; FROM Users"<BR>&#039;********************************** *********<BR>Set rsNewID = Server.CreateObject("ADODB.RecordSet")<BR>rsNewID. Open SQLQuery, db, adOpenKeyset, adLockOptimistic<BR>&#039;************************ *******************<BR>Response.Write rsNewID("NewID")

  2. #2
    Join Date
    Dec 1969

    Default RE: SELECT Max() as 'newID' FROM ...

    SQLQuery = "SELECT Max(ID)+1 as NewID FROM Users"<BR>SQLQuery = "SELECT Max(ID)+1 as [NewID] FROM Users" <BR>also try to change field name ID,can be reserved word..<BR>

  3. #3
    Join Date
    Dec 1969

    Default Right!

    Right answer.<BR><BR>If he had tried RS(0) to read the value being returned, he would have discovered that the *value* was &#039;newID&#039; !!<BR><BR>The quotes make it into a literal string to be returned, *NOT* the name of a field.<BR><BR>

Posting Permissions

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