A ver, esto es muy sencillo, ASP ejecuta el trabajo por lotes, es decir, primero ejecuta lo que está más arriba, tu aquí declaras la variable:
Código PHP:
Dim Ad
Dim Ad_numRows
Dim Repeat1__numRows
Dim Repeat1__index
Dim fac
Dim uni
Dim numPlaz
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"
Ad.CursorType = 0
Ad.CursorLocation = 2
Ad.LockType = 1
Ad.Open()
Ad_numRows = 0
Aquí ejecutas un update:
Código PHP:
<%
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_Conexion1_STRING
Command1.CommandText = "UPDATE [Admitidos] SET NOTA= 30, CANDIDATO=true, SUPLENTE=true WHERE UNIVERSIDAD= '" + Replace(uni, "'", "''") + "' AND FACULTAD='" + Replace(fac, "'", "''") + "' ;"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
%>
Y luego aquí, le pasas el valor a la variable:
Código PHP:
<% While ((Repeat1__numRows <> 0) AND (NOT Ad.EOF)) %>
<BR><%fac=(Ad.Fields.Item("FACULTAD").Value)%><B R />
<BR><%uni=(Ad.Fields.Item("UNIVERSIDAD").Value)%>< B R />
<BR><%numPlaz=(Ad.Fields.Item("NUM PLAZAS").Value)%><BR />
<%
If (numPlazas <> "") Then
Command1.Execute()
End If
%>
<%Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Ad.MoveNext()%>
<%WEND%>
Eso significa que cuando haces esto:
Código PHP:
Command1.CommandText = "UPDATE [Admitidos] SET NOTA= 30, CANDIDATO=true, SUPLENTE=true WHERE UNIVERSIDAD= '" + Replace(uni, "'", "''") + "' AND FACULTAD='" + Replace(fac, "'", "''") + "' ;"
Lo que realmente está escribiendo tu código es esto:
Código PHP:
UPDATE [Admitidos] SET NOTA= 30, CANDIDATO=true, SUPLENTE=true WHERE UNIVERSIDAD= '' AND FACULTAD='' ;
Porque cuando haces la SQL, las variables NO tienen valor declarado, ¿entiendes?
Abajo las escribirá bien porque ya le has pasado un valor en el While.
un saludo.