Results 1 to 4 of 4

Thread: CODE DEBUGGING - L00k!

  1. #1
    Tom Levesque Guest

    Default CODE DEBUGGING - L00k!

    This is my code:<BR><BR>SQLQuery = "SELECT Max(relID) FROM newsrels;"<BR><BR>Set idnums = conn.Execute(SQLQuery)<BR><BR>idnums("relID") = idnums("relID") + 1<BR><BR>I&#039m trying to get the maximum relID and add one to it. The last line produces an error - <BR><BR>ADODB.Fields error &#039 800a0cc1&#039 <BR><BR>ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application. <BR><BR>/wpl/news/newsadmin.asp, line 73 <BR><BR>I suppose this means it can&#039t find relID but when I did a TypeName() on $idnums it said it was a "recordset" therefore relID should be there as it is in the SELECT statement! Please help!<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: CODE DEBUGGING - L00k!

    You need to give the result an alias:<BR><BR>SQLQuery = "SELECT Max(relID) as foo FROM newsrels;"<BR>Set idnums = conn.Execute(SQLQuery)<BR>myValue= idnums("foo") + 1<BR><BR>Or, use the same query and use the ordinal ref:<BR>idnums(0)

  3. #3
    SPG Guest

    Default RE: CODE DEBUGGING - L00k!

    When you use the Max(), you&#039re getting an aggregate function. This means that your query returns a value which doesn&#039t necessarily relate to anything, and therefore can&#039t be easily related back to it.<BR><BR>Try this instead: select top 1 relID from newsrels order by relID<BR><BR>It&#039ll probably go a little bit slower (if any), but it should do what you want it to.

  4. #4
    Tom Levesque Guest

    Default RE: CODE DEBUGGING - L00k!

    Thanks guys, didn&#039t know that. You fixed my problem. :)

Posting Permissions

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