I'm trying to build a SQL statement within my ASP code that will query my Oracle database but it keeps giving me an error. I don't know what I can't use the MAX function within my SQL statement. Pretty much I want to find the maximum ID number within a column. Here's the information:
I tried the same SQL statement in Oracle SQL *Plus.. and the statement works..... meaning at least I get an answer. Here's what it looks like in SQL *Plus......... -->
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> select max(sample_id_no) from C1234567.SAMPLE;
MAX(SAMPLE_ID_NO)
-----------------
52
______________________________________:)
Now here's my code:
<%
Option Explicit
Dim strConnect
%>
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<HTML>
<HEAD>
<TITLE>Using SQL's SELECT Command and the ADO Command Object</TITLE>
</HEAD>
<BODY>
<%
Dim objCommand, objRS
Set objCommand = Server.CreateObject("ADODB.Command")
objCommand.ActiveConnection = strConnect
objCommand.CommandText = "SELECT MAX(sample_id_no) from SAMPLE"
Dim CommandText
Response.Write objCommand.CommandText & "<br>"
'CommandType property to indicate that the command is a SQL statement.
objCommand.CommandType = adCmdText
Set objRS = objCommand.Execute
Set objCommand = Nothing
'Throws an error here
Response.Write objRS("SAMPLE_ID_NO") & "<br>"
objRS.Close
Set objRS = Nothing
%>
______________________________________
And here's the error:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/SQLSelect.asp, line 31
------------------------------------------------
Any suggestions?
Thanks!
-Coby