Ver Mensaje Individual
  #13 (permalink)  
Antiguo 16/04/2012, 05:20
musu143
 
Fecha de Ingreso: abril-2012
Mensajes: 20
Antigüedad: 12 años
Puntos: 1
Respuesta: URGENTE:capturar datos para actualizar consulta

Hola de nuevo a ver si me puedes contestar otra duda que me surge. Despues de ejecutar la primera actualizacion, quiero que, a partir de las variables que me recoge, inserte otro update, un delete y otro update. Si meto el update justo detras me da error, de esta forma:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/Conexion1.asp" -->
<%

Dim Ad
Dim Ad_numRows
Dim Repeat1__numRows
Dim Repeat1__index
Dim fac
Dim uni
Dim numPlaz
Dim nif

Repeat1__numRows = -1
Repeat1__index = 0
Ad_numRows = Ad_numRows + Repeat1__numRows

Set Ad = Server.CreateObject("ADODB.Recordset")
Ad.ActiveConnection = MM_Conexion1_STRING
Ad.Source = "SELECT * FROM Admitidos ORDER BY OPCION, NOTA"
Ad.CursorType = 0
Ad.CursorLocation = 2
Ad.LockType = 1
Ad.Open()
Ad_numRows = 0
%>

<html>
<head>
</head>
<body>

<% While ((Repeat1__numRows <> 0) AND (NOT Ad.EOF)) %>

<BR><%fac=(Ad.Fields.Item("FACULTAD").Value)%><B R/>
<BR><%uni=(Ad.Fields.Item("UNIVERSIDAD").Value)%>< BR>
<BR><%numPlaz=(Ad.Fields.Item("NUM PLAZAS").Value)%><BR/>
<BR><%nif=(Ad.Fields.Item("NIF").Value)%><BR/>

<%
If (numPlaz > 0) Then

set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_Conexion1_STRING
Command1.CommandText = "UPDATE [Admitidos] SET NOTA= 0, CANDIDATO=true, SUPLENTE=false WHERE UNIVERSIDAD= '" + Replace(uni, "'", "''") + "' AND FACULTAD='" + Replace(fac, "'", "''") + "' ;"

Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()

set Command2 = Server.CreateObject("ADODB.Command")
Command2.ActiveConnection = MM_Conexion1_STRING
Command2.CommandText = "UPDATE Admitidos [NUM PLAZAS]=[NUM PLAZAS]-1 WHERE UNIVERSIDAD= '" + Replace(uni, "'", "''") + "' AND FACULTAD='" + Replace(fac, "'", "''") + "' ; "
Command2.CommandType = 1
Command2.CommandTimeout = 0
Command2.Prepared = true
Command2.Execute()


End If
%>

<%Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Ad.MoveNext()%>
<%WEND%>

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


Alguna idea??