Actualizar y Borrar Registro

09/01/2004 - 17:43 por Daniel Villa | Informe spam
Hola Grupo:

Estoy utilizando una pagina en donde tengo dos botones, Grabar y Dar de
Baja.

En ellos, al hacer clic, me llama a los sub Grabar o sub Baja, dependiendo
de lo que haga. Sin embargo, no funciona y no tengo la manera, en que parte
tengo el error.

Les proporciono las funciones y ojalá alguien gentilmente me oriente al
respecto

-
-
<script language="VbScript">
<!--
sub guardar_onclick
vLogin = Request.Form("Select1")
vLogin1=Login.value
vPassword=Password.value
if D1.selectedIndex=1 then
vNivel="Administrador"
end if
if D1.selectedIndex=2 then
vNivel="Coordinador"
end if
if D1.selectedIndex=3 then
vNivel="Lider"
end if
if D1.selectedIndex=4 then
vNivel="Supervisor"
end if
if D1.selectedIndex=5 then
vNivel="Usuario"
end if
' MSGBOX("GUARDAR"+vLogin1+vPassword+vNivel)
' MSGBOX(VLogin)
' strProvider = "Provider = Microsoft.JET.OLEDB.4.0;Data Source C:\Intranet\bdIntranet.mdb;"
' Set objConn = CreateObject("ADODB.Connection")
objConn.Open strProvider
strQuery = "UPDATE tUsuario SET LOGIN='" & vLogin1 & "', ;"
strQuery = strQuery & "PASS='" & vPassword & "', ;"
strQuery = strQuery & "NIVEL='" & vNivel & "'"
strQuery = strQuery & "WHERE Login='" & vLogin & "'"
Set objRS = objConn.Execute(strQuery)
msgbox(strQuery)
end sub


sub baja_onclick
Dim objConn, strQuery, objRS, strProvinder, Correcto, vLogin,
vPassword, vNivel
vLogin = Request.Form("Select1")
strProvider = "Provider = Microsoft.JET.OLEDB.4.0;Data Source
= C:\Intranet\bdIntranet.mdb;"
Set objConn = CreateObject("ADODB.Connection")
objConn.Open strProvider
strQuery = "DELETE FROM tUsuario Where login = '" & vLogin &
"' ;"
Set objRS = objConn.Execute(strQuery)
MSGBOX("BAJA"+vlogin)

end sub

</SCRIPT>

-

He intentado aplicar los MSGBox para checar los valores sin embargo no los
hace, y solo me muestra en la parte inferior de la página, el signo de
exclamación de color amarillo, diciendo error de página

Salu2 :-<
 

Leer las respuestas

#1 Jhonny Vargas P. [MS MVP]
09/01/2004 - 22:12 | Informe spam
Hola Daniel,

Lo que estás haciendo es realizar los Querys en la misma página, para esto
deberías ejecutar todo tu código en el lado del servidor y no del cliente.

¿porque?, porque estás mostrando todas tus conecciones y donde se encuentra
la base de datos, fuera de eso, deberías darle permiso a la base de datos
(al directorio) a todos los usuarios que se conectan a tu página.

Te sugiero que hagas algo similar a esto:

<%
Dim Accion
Accion = Request("Accion")

If Accion="Grabar" Then
ProcedimientoGrabar()
ElseIf Accion="Dar Baja" Then
ProcedimientoDarBaja()
End If

%>

<html>
<body>
<form name="datos" action="pagina.asp" method="post">

<!-- AQUI COLOCAR TUS CONTROLES -->

<br>
<br>
<input type="submit" name="Accion" value="Grabar">&nbsp;
<input type="submit" name="Accion" value="Dar Baja">
</form>
</body>

</html>

<%
'Procedimientos anteriores.
Sub ProcedimientoGrabar()
'COLOCAR CODIGO PARA GRABAR
End Sub

Sub ProcedimientoDarBaja()
'COLOCAR CODIGO PARA DAR DE BAJA
End Sub
%>


Espero que me entiendas el ejemplo.


Saludos,
Jhonny Vargas P. [MS MVP-ASP]
Santiago de Chile
Sitio MVPs Chile http://www.mvp.cl




"Daniel Villa" escribió en el
mensaje news:uN0Dq#
Hola Grupo:

Estoy utilizando una pagina en donde tengo dos botones, Grabar y Dar de
Baja.

En ellos, al hacer clic, me llama a los sub Grabar o sub Baja, dependiendo
de lo que haga. Sin embargo, no funciona y no tengo la manera, en que


parte
tengo el error.

Les proporciono las funciones y ojalá alguien gentilmente me oriente al
respecto

-
<script language="VbScript">
<!--
sub guardar_onclick
vLogin = Request.Form("Select1")
vLogin1=Login.value
vPassword=Password.value
if D1.selectedIndex=1 then
vNivel="Administrador"
end if
if D1.selectedIndex=2 then
vNivel="Coordinador"
end if
if D1.selectedIndex=3 then
vNivel="Lider"
end if
if D1.selectedIndex=4 then
vNivel="Supervisor"
end if
if D1.selectedIndex=5 then
vNivel="Usuario"
end if
' MSGBOX("GUARDAR"+vLogin1+vPassword+vNivel)
' MSGBOX(VLogin)
' strProvider = "Provider = Microsoft.JET.OLEDB.4.0;Data Source
C:\Intranet\bdIntranet.mdb;"
' Set objConn = CreateObject("ADODB.Connection")
objConn.Open strProvider
strQuery = "UPDATE tUsuario SET LOGIN='" & vLogin1 & "', ;"
strQuery = strQuery & "PASS='" & vPassword & "', ;"
strQuery = strQuery & "NIVEL='" & vNivel & "'"
strQuery = strQuery & "WHERE Login='" & vLogin & "'"
Set objRS = objConn.Execute(strQuery)
msgbox(strQuery)
end sub


sub baja_onclick
Dim objConn, strQuery, objRS, strProvinder, Correcto, vLogin,
vPassword, vNivel
vLogin = Request.Form("Select1")
strProvider = "Provider = Microsoft.JET.OLEDB.4.0;Data


Source
= C:\Intranet\bdIntranet.mdb;"
Set objConn = CreateObject("ADODB.Connection")
objConn.Open strProvider
strQuery = "DELETE FROM tUsuario Where login = '" & vLogin &
"' ;"
Set objRS = objConn.Execute(strQuery)
MSGBOX("BAJA"+vlogin)

end sub

</SCRIPT>


He intentado aplicar los MSGBox para checar los valores sin embargo no los
hace, y solo me muestra en la parte inferior de la página, el signo de
exclamación de color amarillo, diciendo error de página

Salu2 :-<



Preguntas similares