Foros del Web » Programando para Internet » ASP Clásico »

Duda modificacion funcion Ugoldman

Estas en el tema de Duda modificacion funcion Ugoldman en el foro de ASP Clásico en Foros del Web. He estado viendo esta funcion que puso Ugoldman en la biblioteca: <% Function GetMyMaxId(table, field) Set rsGetMyMaxId = Server.CreateObject("ADODB.Recordset") strSQLGetMyMaxId = "SELECT MAX(" & field ...
  #1 (permalink)  
Antiguo 10/02/2005, 03:55
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 21 años, 1 mes
Puntos: 0
Duda modificacion funcion Ugoldman

He estado viendo esta funcion que puso Ugoldman en la biblioteca:
<%
Function GetMyMaxId(table, field)
Set rsGetMyMaxId = Server.CreateObject("ADODB.Recordset")
strSQLGetMyMaxId = "SELECT MAX(" & field & ") AS myMax FROM " & table
rsGetMyMaxId.Open strSQLGetMyMaxId, ObjConn, 3, 3
fnctMyMaxId = rsGetMyMaxId("myMax")
If IsNull(fnctMyMaxId) Then
fnctMyMaxId = 0
End If
rsGetMyMaxId.Close
Set rsGetMyMaxId = Nothing
GetMyMaxId = fnctMyMaxId
End Function
%>

Llamada a la función

Cita:
MaxID = GetMyMaxId("tabla", "campo")


¿Como podria modificar la funcion para que me proporcionase en lugar del valormaximo que toma el campo, el autonumerico(clave principal) de la tabla?


GetMyMaxId("autonumerico" ,"tabla", "campo")
  #2 (permalink)  
Antiguo 10/02/2005, 04:52
Avatar de Muzztein  
Fecha de Ingreso: agosto-2002
Ubicación: Hangar 18
Mensajes: 1.703
Antigüedad: 21 años, 9 meses
Puntos: 16
algo asi ???


<%
Function GetMyMaxId(table, field)
Set rsGetMyMaxId = Server.CreateObject("ADODB.Recordset")

strSQLGetMyMaxId = "SELECT MAX(" & field & ") AS myMax , "& autonumerico &" as PK FROM " & table

rsGetMyMaxId.Open strSQLGetMyMaxId, ObjConn, 3, 3
fnctMyMaxId = rsGetMyMaxId("myMax") & "," & rsGetMyMaxId("PK")


If IsNull(fnctMyMaxId) Then
fnctMyMaxId = false
End If

rsGetMyMaxId.Close
Set rsGetMyMaxId = Nothing
GetMyMaxId = fnctMyMaxId
End Function
%>


y luego la capturas con un split por coma...

or something
  #3 (permalink)  
Antiguo 10/02/2005, 05:20
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 21 años, 1 mes
Puntos: 0
Muzztein gracias por tu ayuda, obtengo este error:
Tipo de error:
ADODB.Recordset (0x800A0BB9)
Argumentos incorrectos, fuera del intervalo permitido o en conflicto con otros.
/webgs/admin/test1.asp, línea 12
¿Puede ser debido a las constantes de la conexion 3,3?
Nota: y luego la capturas con un split por coma...
Esto no lo necesitaria porque lo unico que quiero obtener es el idproducto,
mira que he puesto:
fnctMyMaxId =rsGetMyMaxId("PK")
y no
fnctMyMaxId = rsGetMyMaxId("myMax") & "," & rsGetMyMaxId("PK")


<%
Function GetMyMaxId(autonumerico,table, field)
Set rsGetMyMaxId = Server.CreateObject("ADODB.Recordset")
strSQLGetMyMaxId = "SELECT MAX(" & field & ") AS myMax , "& autonumerico &" as PK FROM " & table
'Response.Write(strSQLGetMyMaxId)
'Response.End()
rsGetMyMaxId.Open strSQLGetMyMaxId, ObjConn, 3, 3
fnctMyMaxId =rsGetMyMaxId("PK")
If IsNull(fnctMyMaxId) Then
fnctMyMaxId = false
End If
rsGetMyMaxId.Close
Set rsGetMyMaxId = Nothing
GetMyMaxId = fnctMyMaxId
End Function
%>
<%=GetMyMaxId("idproducto","productos", "lecturas") %>

Última edición por sqa212; 10/02/2005 a las 05:23
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:00.