Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/05/2007, 11:49
figey
 
Fecha de Ingreso: mayo-2007
Mensajes: 2
Antigüedad: 17 años, 11 meses
Puntos: 0
sos-->Borrar un registro de una tabla

Hola a todos!!
soy novatillo en ASP y estoy terminando una pequeña base de datos pero no hay manera de poder terminarla!!
estoy estancado en poder borrar un registro de una tabla!!
lo he hecho con dos archivos asp!!!
uno q se llama borra_registres2.asp con el codigo:
<html>
<head>
<title> base de dades figey</title>
</head>
<body>
<H1>Ejemplo de uso de bases de datos con ASP y ADO</H1>
<form action="borrar_2.asp" method="post" name="accion" id="accion">
<TABLE>
<TR>
<TD>Nombre:</TD>
<TD><INPUT TYPE="text" NAME="Nom" SIZE="20" MAXLENGTH="30"></TD>
</TR>
<TR>
<TD>Apellidos:</TD>
<TD><INPUT TYPE="text" NAME="Cognoms" SIZE="20" MAXLENGTH="30"></TD>
</TR>
</TABLE>
<INPUT NAME="accion" TYPE="submit" id="accion" VALUE="Borrar Registro">
</FORM>
<hr>
<%
Dim oConn,strSQL, objRS

Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("basedades.mdb"))

strSQL = "SELECT * FROM dades"
Set objRS = oConn.Execute(strSQL)

%>
<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR><TD><strong>&nbsp;Nombre</strong></TD>
<TD>&nbsp;<strong>Apellidos&nbsp;</strong></TD>
</TR>
<%

while (not objRS.Eof)
Response.Write("<tr><td>&nbsp;" & objRS("Nom") & "</td><td>&nbsp;" & objRS("Cognoms") & "&nbsp;</td></tr>")
objRS.MoveNext

wend

oConn.Close
set objRS = nothing
set oConn = nothing

%>
</table>
</body>
</html>


i el otro q es donde creo q tengo el fallo se llama borrar_2.asp:
<%
Dim oConn,strSQL

Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("basedades.mdb"))

strSQL = "delete from dades where Nom = " & Request.QueryString("id")
oConn.Execute(strSQL)
oConn.Close
set oConn = nothing

Response.Redirect("borra_registres2.asp")
%>


creol q el problema esta en la sentecia strSQL = "delete from dades where Nom = " & Request.QueryString("id") ya q la primera parte me funciona perfectamente!!!
AGRADECERIA MUCHO VUESTRA AYUDA!!!
MUCHISSIMAS GRACIAS