Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá,Gostaria de uma ajuda, nunca trabalhei com banco de dados mas pesquisando na internet, andei conseguindo fazer algumas coisas, como consultar e incluir registros, porém na alteração não estou conseguindo fazer, até aparece que foi feito com sucesso porém não altera.Abaixo os códigos:*************************ALTERAR.ASP*******************************<%Caminho = Server.MapPath("noticias.mdb")strConn = "Provider = Microsoft.jet.oledb.4.0; Data Source=" & CaminhoSet Conn = Server.CreateObject("adodb.connection")Conn.Open(strConn)set rstemp=Conn.execute("select * from news")If Err.Number<>0 ThenResponse.Write(Err.Description)ElseResponse.Write("Conexão está OK")End If%><table border=1><% response.write "<tr>" for each item in rstemp.fields response.write "<td><B>" & item.name & "</B></TD>" next response.write "</tr>"DO UNTIL rstemp.eof chamada=rstemp("chamada") link=rstemp("link") noticia=rstemp("noticia") 'cellstart="<td align=""top"">" response.write "<tr>" response.write "<td>" & chamada & "</td>" response.write "<td><A HREF=" & "alterar_1.asp?id=" & chamada & ">" & link & "</a></td>" response.write "<td>" & noticia & "</td>" response.write "</tr>" rstemp.movenextLOOP%></table><%rstemp.closeset rstemp=nothingConn.closeset conntemp=nothing%>**********************ALTERAR_1.ASP********************************<%Caminho = Server.MapPath("noticias.mdb")strConn = "Provider = Microsoft.jet.oledb.4.0; Data Source=" & CaminhoSet Conn = Server.CreateObject("adodb.connection")Conn.Open(strConn)chamada=clng(request.querystring("id")) sqltemp="Select * From news Where chamada=" & chamada set rstemp=conn.execute(sqltemp)form_chamada=rstemp("chamada") form_link=rstemp("link") form_noticia=rstemp("noticia") rstemp.close set rstemp=nothing conn.close set conn=nothing %> <body> <p><B><font size=4>Formulário com os dados selecionados para alteração </font></b></P> <hr> <form name="altera" action="alterar_2.asp" method="POST"> <input type="hidden" name="chamada" value="<%=form_chamada%>"> <p>Código: <%=form_chamada%> </p> <p> Link : <input name="link" type="TEXT" id="link" value="<%=form_link%>"> </p> <p> Noticia : <input name="noticia" type="TEXT" id="noticia" value="<%=form_noticia%>"> </p> <p> <input type="SUBMIT" Value="Gravar as Alterações"> </p> <hr></form> </table>*********************ALTERAR_2.ASP********************************<% chamada=request.form("chamadaa")link=request.form("linkk")noticia=request.form("noticiaa") Caminho = Server.MapPath("noticias.mdb")strConn = "Provider = Microsoft.jet.oledb.4.0; Data Source=" & CaminhoSet Conn = Server.CreateObject("ADODB.Connection") Conn.open(strConn)set rstemp=Conn.execute("select * from news") SQL = "UPDATE news SET"SQL = SQL & "link='" & link & "',"SQL = SQL & "noticia='" & noticia & "',"SQL = SQL & "WHERE chamada=" & chamada Set RS = Conn.Execute(SQL) response.write "<B>Alterações gravadas com sucesso !!!</b>" response.write "<hr>" response.write "<br>" response.write "<br>" & "Os novos dados são : " response.write "<br>" response.write "<br>" & "link - " & link response.write "<br>" & "noticia - " & noticia response.write "<br>" & "chamada - " & chamada rstemp.closeset rstemp=nothingConn.Closeset Conntemp=nothing%><hr><a href="consultar.asp">Voltar</a>Desde já agradeçoFábio SantosCarregando comentários...