Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How i can use the function max from sql in asp, look the question 1

Status
Not open for further replies.

Karlita

Programmer
Feb 5, 2003
2
0
0
CR
I have this code, i want to read the maximun number of a index in one table.
My table name is consultas and the key name is nroconsulta,
i know that in the oRS is the result of the select but,
How i cant get it??

This is the code:

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\kvillalobos\db\dbcsi.mdb"))

'Select the last index number in the db
sSQL ="select max(nroconsulta) from consultas"
Set oRS = oConn.Execute(sSQL)

if NOT oRS.EOF then

' Response.Write(oRS("nroconsulta"))
'That is the big question,how i can get the number that have oRS, the result of the max function in sql.

end if
 
Hi
If i get what you are trying to say .....
if you dont give an alias to the field then you can access it using oRS(0).Value or you can alias the field
SELECT MAX(nroconsulta) AS nroconsulta
 
Thanks you, about the alias in sql.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top