Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/04/2012, 15:40
musu143
 
Fecha de Ingreso: abril-2012
Mensajes: 20
Antigüedad: 12 años
Puntos: 1
Pregunta Alguien puede decirme como resolver este codigo???

Tengo este codigo y me da el error que especifico debajo:

<%@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
Dim opc
Dim can
Dim sup

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
%>



<% 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/>
<BR><%opc=(Ad.Fields.Item("OPCION").Value)%><BR/>

<%
If (numPlaz > 0) Then 'Si el numero de plazas de la fila que es leida es mayor que cero, actualiza ese NIF a CANDIDATO=true, SUPLENTE=false'


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

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



'Sigue dentro del if. Como ya tiene un candidato en esa universidad/facultad, debe de actualizar el numero de plazas, con lo cual, le resta una en todas las filas donde aparezca el par universidad/facultad'

set Command2 = Server.CreateObject("ADODB.Command")
Command2.ActiveConnection = MM_Conexion1_STRING
Command2.CommandText = "UPDATE Admitidos SET [NUM PLAZAS]='" + Replace(numPlaz-&1, "'", "''") + "' WHERE UNIVERSIDAD= '" + Replace(uni, "'", "''") + "' AND FACULTAD='" + Replace(fac, "'", "''") + "' ;"

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


'Despues de ejecutar la consulta, lee los datos de candidato y suplente para ver si tiene que seguir haciendo actualizacion o borrado de filas'

can=(Ad.Fields.Item("CANDIDATO").Value)
sup=(Ad.Fields.Item("SUPLENTE").Value)


%>

<%
If can=true Then 'Si ha encontrado un candidato, debe mirar si el nif de ese candidato aparece mas veces en la tabla y tiene mas veces el campo candidato=true. Si es asi, mira la opcion y si esta ultima es menos, borra la fila primera ya que candidatos con menos opcion se borran de la tabla'

set Command3 = Server.CreateObject("ADODB.Command")
Command3.ActiveConnection = MM_Conexion1_STRING
Command3.CommandText = "DELETE Id FROM Admitidos WHERE NIF = '" + Replace(nif, "'", "''") + "' AND ('" + Replace(opc, "'", "''") + "' > EXISTS(SELECT OPCION FROM Admitidos WHERE NIF = '" + Replace(nif, "'", "''") + "' AND CANDIDATO=true));"

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



'Si ha entrado en ese if, quiere decir que ha borrado esa fila, por tanto, debemos actualizar una vez mas el numero de plazas, ya que habria otra vacante es esa universidad/facultad que hemos borrado
'
set Command4 = Server.CreateObject("ADODB.Command")
Command4.ActiveConnection = MM_Conexion1_STRING
Command4.CommandText = "UPDATE [Admitidos] SET [NUM PLAZAS]='" + Replace(numPlaz+&1, "'", "''") + "' WHERE UNIVERSIDAD= '" + Replace(uni, "'", "''") + "' AND FACULTAD='" + Replace(fac, "'", "''") + "' ;"

Command4.CommandType = 1
Command4.CommandTimeout = 0
Command4.Prepared = true
Command4.Execute()
end if%>




<% If sup=true then 'Aqui hacemos lo mismo que antes, si suplente=true, miramos si hay por encima y borramos este, pero aqui no cambiamos el numero de plazas ya que eso solo afecta a los que son candidatos, pues los suplentes no restan plaza'

set Command5 = Server.CreateObject("ADODB.Command")
Command5.ActiveConnection = MM_Conexion1_STRING
Command5.CommandText = "DELETE Id FROM Admitidos WHERE NIF = '" + Replace(nif, "'", "''") + "' AND '" + Replace(opc, "'", "''") + "' > EXISTS (SELECT OPCION FROM Admitidos WHERE NIF = '" + Replace(nif, "'", "''") + "' AND SUPLENTE=true);"

Command5.CommandType = 1
Command5.CommandTimeout = 0
Command5.Prepared = true
Command5.Execute()
end if
%>



<%
else 'este es el else del primer if, sino hay plazas libres pero coincide universidad/facultad y nif leido, pasa a ser suplente'

set Command6 = Server.CreateObject("ADODB.Command")
Command6.ActiveConnection = MM_Conexion1_STRING
Command6.CommandText = "UPDATE Admitidos SET CANDIDATO=false, SUPLENTE=true WHERE UNIVERSIDAD= '" + Replace(uni, "'", "''") + "' AND FACULTAD='" + Replace(fac, "'", "''") + "' and NIF = '" + Replace(nif, "'", "''") + "';"

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

End If
%>




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

<html >
<head>

</head>

<body>
</body>
</html>

<%
Ad.Close()
Set Ad = Nothing
%>




Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][Controlador ODBC Microsoft Access] No se pudo actualizar; actualmente está bloqueado por el usuario 'admin' en la máquina 'luis-PC'.

/index.asp, línea 100