Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

maurohpg

Excluir campos do BD

Recommended Posts

Fiz um sisteminha para excluir dados do BD atraves de checkbox, qdo a pessoa selecionar o checkbox de um certo compo ele irá excluir apenas aquele registro, está funcionando, mais qdo seleciono por exemplo do registro 33 ele apaga o do 32 ou do 34 não estou intendendo o pq disso, já que mostrar na dela ele está mostrando e estou excluindo pelo ID que é de auto numeração. Se alguém puder me ajudar fiz no dreamweaver, vou postar o código caso alguém saiba.

 

ASP

[*]

 

[*]<%@LANGUAGE="VBSCRIPT"%>

 

[*]<!--#include file="../Connections/globalfood.asp" -->

 

[*]<%

 

[*]' *** Edit Operations: declare variables

 

[*]

 

[*]Dim MM_editAction

 

[*]Dim MM_abortEdit

 

[*]Dim MM_editQuery

 

[*]Dim MM_editCmd

 

[*]

 

[*]Dim MM_editConnection

 

[*]Dim MM_editTable

 

[*]Dim MM_editRedirectUrl

 

[*]Dim MM_editColumn

 

[*]Dim MM_recordId

 

[*]

 

[*]Dim MM_fieldsStr

 

[*]Dim MM_columnsStr

 

[*]Dim MM_fields

 

[*]Dim MM_columns

 

[*]Dim MM_typeArray

 

[*]Dim MM_formVal

 

[*]Dim MM_delim

 

[*]Dim MM_altVal

 

[*]Dim MM_emptyVal

 

[*]Dim MM_i

 

[*]

 

[*]MM_editAction CStr(Request.ServerVariables("SCRIPT_NAME"))

 

[*]If (Request.QueryString <> ""Then

 

[*] MM_editAction = MM_editAction & "?" & Request.QueryString

 

[*]End If

 

[*]

 

[*]' boolean to abort record edit

 

[*]MM_abortEdit false

 

[*]

 

[*]' query string to execute

 

[*]MM_editQuery ""

 

[*]%>

 

[*]<%

 

[*]' *** Delete Record: declare variables

 

[*]

 

[*]if (CStr(Request("MM_delete")) "form1" And CStr(Request("MM_recordId")) <> ""Then

 

[*]

 

[*] MM_editConnection = MM_globalfood_STRING

 

[*] MM_editTable "eventos"

 

[*] MM_editColumn "id"

 

[*] MM_recordId "" + Request.Form("MM_recordId") + ""

 

[*] MM_editRedirectUrl "excluido.asp"

 

[*]

 

[*] ' append the query string to the redirect URL

 

[*] If (MM_editRedirectUrl <> "" And Request.QueryString <> ""Then

 

[*] If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> ""Then

 

[*] MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString

 

[*] Else

 

[*] MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString

 

[*] End If

 

[*] End If

 

[*]

 

[*]End If

 

[*]%>

 

[*]<%

 

[*]' *** Delete Record: construct a sql delete statement and execute it

 

[*]

 

[*]If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> ""Then

 

[*]

 

[*] ' create the sql delete statement

 

[*] MM_editQuery "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

 

[*]

 

[*] If (Not MM_abortEdit) Then

 

[*] ' execute the delete

 

[*] Set MM_editCmd Server.CreateObject("ADODB.Command")

 

[*] MM_editCmd.ActiveConnection = MM_editConnection

 

[*] MM_editCmd.CommandText = MM_editQuery

 

[*] MM_editCmd.Execute

 

[*] MM_editCmd.ActiveConnection.Close

 

[*]

 

[*] If (MM_editRedirectUrl <> ""Then

 

[*] Response.Redirect(MM_editRedirectUrl)

 

[*] End If

 

[*] End If

 

[*]

 

[*]End If

 

[*]%>

 

[*]

 

[*]<%

 

[*]Dim RSeventos

 

[*]Dim RSeventos_numRows

 

[*]

 

[*]Set RSeventos Server.CreateObject("ADODB.Recordset")

 

[*]RSeventos.ActiveConnection = MM_globalfood_STRING

 

[*]RSeventos.Source "SELECT * FROM eventos ORDER BY id DESC"

 

[*]RSeventos.CursorType = 0

 

[*]RSeventos.CursorLocation = 2

 

[*]RSeventos.LockType = 1

 

[*]RSeventos.Open()

 

[*]

 

[*]RSeventos_numRows = 0

 

[*]%>

 

[*]<%

 

[*]Dim Repeat1__numRows

 

[*]Dim Repeat1__index

 

[*]

 

[*]Repeat1__numRows = 10

 

[*]Repeat1__index = 0

 

[*]RSeventos_numRows = RSeventos_numRows + Repeat1__numRows

 

[*]%>

 

[*]<html>

 

[*]<head>

 

[*]<title>Documento sem título</title>

 

[*]<link href="css.css" rel="stylesheet" type="text/css">

 

[*]<style type="text/css">

 

[*]<!--

 

[*].style2 {

 

[*] color: #F4F4F4;

 

[*] font-size: 9px;

 

[*]}

 

[*]-->

 

[*]</style>

 

[*]</head>

 

[*]

 

[*]<body>

 

[*]<table width="100%" border="0" cellspacing="0" cellpadding="0">

 

[*] <tr> 

 

[*] <td height="67" bgcolor="#CCCCCC"

 

[*] <table width="100%" border="0" cellspacing="1" cellpadding="0">

 

[*] <tr> 

 

[*] <td height="18" class="tableMainTitulo"><b>  Excluir Eventos</b></td>

 

[*] </tr>

 

[*] <tr> 

 

[*] <td height="46" bgcolor="#F4F4F4"><span class="textoMain"> </span> 

 

[*] <form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1">

 

[*]<input type="hidden" name="MM_recordId" value="<%RSeventos.Fields.Item("id").Value %>">

 

[*]<% 

 

[*]While NOT RSeventos.EOF

 

[*]%>

 

[*] <table width="100%" border="0" cellspacing="0" cellpadding="0">

 

[*] <tr> 

 

[*] <td width="84%" bgcolor="#E5E5E5"><font size="1" face="Arial, Helvetica, sans-serif">  <%=(RSeventos.Fields.Item("evento").Value)%></font></td>

 

[*] <td width="16%" bgcolor="#E5E5E5"><input type="checkbox" name="checkbox" value="checkbox"

 

[*] <font size="1" face="Verdana, Arial, Helvetica, sans-serif">excluir</font></td>

 

[*] </tr>

 

[*] <tr>

 

[*] <td height="10" colspan="2"><span class="style2">-</span></td>

 

[*] </tr>

 

[*] </table>

 

[*]<% 

 

[*] Repeat1__index=Repeat1__index+1

 

[*] Repeat1__numRows=Repeat1__numRows-1

 

[*] RSeventos.MoveNext()

 

[*] Wend

 

[*]%>

 

[*] <table width="100%" border="0" cellspacing="5" cellpadding="0">

 

[*] <tr> 

 

[*] <td><input name="busca" type="submit" class="formMainBotao" value="excluir"

 

[*] </td>

 

[*] </tr>

 

[*] </table>

 

[*] <input type="hidden" name="MM_delete" value="form1">

 

[*] </form></td>

 

[*] </tr>

 

[*] </table></td>

 

[*] </tr>

 

[*]</table>

 

[*]</body>

 

[*]</html>

 

[*]<%

 

[*]RSeventos.Close()

 

[*]Set RSeventos = Nothing

 

[*]%>

 

[*]

Compartilhar este post


Link para o post
Compartilhar em outros sites

Conteúdo de um campo da tabela....pq tenho o sisteminha de incluir a noticia e o sisteminha para excluit e num consigu excluir o conteúdo do campo. Ele deleta tuduc ertinho mais ele num deleta como deveria tipo eu tenho um Campo Evento1, Evento2, Evento3, e tenho os checkbox do lado de cada campo e o botão excluir qdo clico pra excluir o 2 ele exlui o 1, tipo meio doido mais exclui.

Compartilhar este post


Link para o post
Compartilhar em outros sites

que erro ta dando??

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.