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

Actualizar registros

Estas en el tema de Actualizar registros en el foro de ASP Clásico en Foros del Web. Hola, tengo un problema y me da un poco de cosa pegar el código pues es un tocho, pero como veo que es lo que ...
  #1 (permalink)  
Antiguo 28/04/2009, 17:22
 
Fecha de Ingreso: agosto-2006
Mensajes: 355
Antigüedad: 18 años, 8 meses
Puntos: 2
Actualizar registros

Hola, tengo un problema y me da un poco de cosa pegar el código pues es un tocho, pero como veo que es lo que suele ser más práctico pues allá voy... son tres páginas: la de búsqueda, la de resultados y la de actualización, el tema es que cuando selecciono un elemento en la de busqueda, me lleva a la de resultados pero siempre sale el mismo registro (el número uno de la tabla).Pongo solo el código de la de búsqueda porque no puedo pegar el código de las dos en el mensaje.

Pagina de búsqueda:

<%
Dim tablacompleta__MMColParam
tablacompleta__MMColParam = "1"
If (Request.QueryString("Id") <> "") Then
tablacompleta__MMColParam = Request.QueryString("Id")
End If
%>
<%
Dim tablacompleta
Dim tablacompleta_numRows

Set tablacompleta = Server.CreateObject("ADODB.Recordset")
tablacompleta.ActiveConnection = MM_connpruebaev_STRING
tablacompleta.Source = "SELECT * FROM Tabla1 WHERE Id = " + Replace(tablacompleta__MMColParam, "'", "''") + " ORDER BY Id ASC"
tablacompleta.CursorType = 0
tablacompleta.CursorLocation = 2
tablacompleta.LockType = 1
tablacompleta.Open()

tablacompleta_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
tablacompleta_numRows = tablacompleta_numRows + Repeat1__numRows
%>
<%


Dim tablacompleta_total
Dim tablacompleta_first
Dim tablacompleta_last

tablacompleta_total = tablacompleta.RecordCount


If (tablacompleta_numRows < 0) Then
tablacompleta_numRows = tablacompleta_total
Elseif (tablacompleta_numRows = 0) Then
tablacompleta_numRows = 1
End If

tablacompleta_first = 1
tablacompleta_last = tablacompleta_first + tablacompleta_numRows - 1

If (tablacompleta_total <> -1) Then
If (tablacompleta_first > tablacompleta_total) Then
tablacompleta_first = tablacompleta_total
End If
If (tablacompleta_last > tablacompleta_total) Then
tablacompleta_last = tablacompleta_total
End If
If (tablacompleta_numRows > tablacompleta_total) Then
tablacompleta_numRows = tablacompleta_total
End If
End If
%>
<%
Dim MM_paramName
%>
<%

Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined

Dim MM_param
Dim MM_index

Set MM_rs = tablacompleta
MM_rsCount = tablacompleta_total
MM_size = tablacompleta_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

' use index parameter if defined, otherwise use offset parameter
MM_param = Request.QueryString("index")
If (MM_param = "") Then
MM_param = Request.QueryString("offset")
End If
If (MM_param <> "") Then
MM_offset = Int(MM_param)
End If

If (MM_rsCount <> -1) Then
If (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move last
If ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If

MM_index = 0
While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
If (MM_rs.EOF) Then
MM_offset = MM_index ' set MM_offset to the last possible record
End If

End If
%>
<%


If (MM_rsCount = -1) Then

MM_index = MM_offset
While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend

' if we walked off the end of the recordset, set MM_rsCount and MM_size
If (MM_rs.EOF) Then
MM_rsCount = MM_index
If (MM_size < 0 Or MM_size > MM_rsCount) Then
MM_size = MM_rsCount
End If
End If

' if we walked off the end, set the offset based on page size
If (MM_rs.EOF And Not MM_paramIsDefined) Then
If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
If ((MM_rsCount Mod MM_size) > 0) Then
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If

If (MM_rs.CursorType > 0) Then
MM_rs.MoveFirst
Else
MM_rs.Requery
End If


MM_index = 0
While (Not MM_rs.EOF And MM_index < MM_offset)
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
End If
%>
<%



tablacompleta_first = MM_offset + 1
tablacompleta_last = MM_offset + MM_size

If (MM_rsCount <> -1) Then
If (tablacompleta_first > MM_rsCount) Then
tablacompleta_first = MM_rsCount
End If
If (tablacompleta_last > MM_rsCount) Then
tablacompleta_last = MM_rsCount
End If
End If


MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%


Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem


MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
End If
Next


For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
End If
Next

MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<%

Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev

Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

If (MM_size > 1) Then
MM_moveParam = "offset"
If (MM_keepMove <> "") Then
MM_paramList = Split(MM_keepMove, "&")
MM_keepMove = ""
For MM_paramIndex = 0 To UBound(MM_paramList)
MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
End If
Next
If (MM_keepMove <> "") Then
MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
End If
End If
End If

If (MM_keepMove <> "") Then
MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If

MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = MM_urlStr & "0"
MM_moveLast = MM_urlStr & "-1"
MM_moveNext = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
MM_movePrev = MM_urlStr & "0"
Else
MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
<%


If (tablacompleta_total = -1) Then

tablacompleta_total=0
While (Not tablacompleta.EOF)
tablacompleta_total = tablacompleta_total + 1
tablacompleta.MoveNext
Wend

If (tablacompleta.CursorType > 0) Then
tablacompleta.MoveFirst
Else
tablacompleta.Requery
End If

If (tablacompleta_numRows < 0 Or tablacompleta_numRows > tablacompleta_total) Then
tablacompleta_numRows = tablacompleta_total
End If

tablacompleta_first = 1
tablacompleta_last = tablacompleta_first + tablacompleta_numRows - 1

If (tablacompleta_first > tablacompleta_total) Then
tablacompleta_first = tablacompleta_total
End If
If (tablacompleta_last > tablacompleta_total) Then
tablacompleta_last = tablacompleta_total
End If

End If
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>

<body>


<div id="content"><div id="modificar">
<form id="form1" name="form1" method="get" action="/pruebaev2/modificar.asp">
<p>Seleccione el n&uacute;mero de ID que desea modificar:</p>
<p>
<select name="select">
<option value="1">1</option>
<option value="2">2</option><option value="3">3</option>

<%
While (NOT tablacompleta.EOF)
%><option value="<%=(tablacompleta.Fields.Item("Id").Value)% >"><%=(tablacompleta.Fields.Item("Id").Value)%> </option>
<%
tablacompleta.MoveNext()
Wend
If (tablacompleta.CursorType > 0) Then
tablacompleta.MoveFirst
Else
tablacompleta.Requery
End If
%>
</select>

<p>
<input type="submit" name="enviar" value="Enviar" />
<A HREF="/pruebaev2/eliminar_pasotres.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & "Id=" & tablacompleta.Fields.Item("Id").Value %>"></A> </p>
</p>
</form>
<br>
</div>
</div>

</body>
</html>
<%
tablacompleta.Close()
Set tablacompleta = Nothing
%>



Muchas gracias
  #2 (permalink)  
Antiguo 28/04/2009, 18:48
Avatar de JuanRAPerez
Colaborador
 
Fecha de Ingreso: octubre-2003
Mensajes: 2.393
Antigüedad: 21 años, 6 meses
Puntos: 27
Respuesta: Actualizar registros

tablacompleta__MMColParam = Request.QueryString("Id")

sera que siempre recibes el mismo id
?????
__________________
JuanRa Pérez
San Salvador, El Salvador
  #3 (permalink)  
Antiguo 29/04/2009, 05:00
 
Fecha de Ingreso: agosto-2006
Mensajes: 355
Antigüedad: 18 años, 8 meses
Puntos: 2
Respuesta: Actualizar registros

Pero es que el Id es el nombre de la columna clave en la comunicación de datos entre los formularios de las páginas, pensaba que había que ponerlo...
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 08:09.