Cita:
Iniciado por mc_quake
FUNCION PARA BUSCAR EL ULTIMO REGISTRO INGRESADO EN LA BD, BASTANTE UTIL
ASI SE LLAMA
ultimodato = sqlmaximo(campo, tabla)
campo = corresponde autonumerico
tabla = tabla que buscas el ultimo registro ingresado
ESTA ES LA FUNCION
Function sqlmaximo( campo, tabla )
on error resume next
sql = "select max("&campo&") as maximo from "&tabla
set rsmax = db.execute(sql)
if err <> 0 then
Response.Write("ERROR :"&err.description&"<hr>")
else
if not rsmax.eof then
sqlmaximo = rsmax("maximo")
end if
rsmax.close
End Function
Pues sí que es útil esto para usar en caso general y aplicado a muchas BDs, pero en el caso concreto de ASP con MySQL, si el tema consiste en usar una conexión extra a la base, el "SELECT * ORDER BY campo DESC LIMIT 1" va de lujo y es bien sencillo de implementar.