Danilo Piovani Posted January 21, 2004 Report Share Posted January 21, 2004 Falae galera ...vocês podem me dar um exemplo de um update no BD Access ...No caso seria via formulário ...Valeu { } ... Quote Link to comment Share on other sites More sharing options...
0 Reginaldo ASP Posted January 21, 2004 Report Share Posted January 21, 2004 UPDATE tabela SET campo=VALOR WHERE CAMPOCHAVE=VALORCHAVE Quote Link to comment Share on other sites More sharing options...
0 Danilo Piovani Posted January 21, 2004 Author Report Share Posted January 21, 2004 Então Galera , o procedimento que eu imagino é o seguinte ...Um funcionário insere um aviso de manutenção ... ( já implementado )dou a opção de consultar os avisos em aberto ... ( já implementado )dentro desta página quero um botão de atualizar , que quando clicado traz todos os campos com os atuais "valores" podendo assim ser modificados e feito o update ...Se você puder me mostrar um código simples disso eu tento colocar dentro do meu padrão ... Valeu Galera... Quote Link to comment Share on other sites More sharing options...
0 bolomaster Posted January 21, 2004 Report Share Posted January 21, 2004 cara posta o seu para vermos e colocar já direto nele .. ok Quote Link to comment Share on other sites More sharing options...
0 Danilo Piovani Posted January 21, 2004 Author Report Share Posted January 21, 2004 O que tem de errado neste ??<html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body bgcolor="#FFFFFF" text="#000000"><form method="post" action="<%=MM_editAction%>" name="form1"> <table align="center" width="611"> <tr valign="baseline"> <td nowrap align="left" width="193"><b> Manutenção em: </b> </td> <td width="404"> <input type="text" name="nome" value="<%=(Recordset1.Fields.Item("servidor").Value)%>" size="27"> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"><b>Será(ão) Impactado(s):</b> </td> <td width="404"> <input type="text" name="endereco" value="<%=(Recordset1.Fields.Item("sistema").Value)%>" size="27"> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"><b> Data da Manutenção: </b> </td> <td width="404"> <input type="text" name="cidade" value="<%=(Recordset1.Fields.Item("dia").Value)%>" size="20"> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"><b> Hora de Início:</b> </td> <td width="404"> <input type="text" name="estado" value="<%=(Recordset1.Fields.Item("inicio").Value)%>" size="12"> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"><b>Tempo de Manutenção:</b> </td> <td width="404"> <input type="text" name="cep" value="<%=(Recordset1.Fields.Item("termino").Value)%>" size="12"> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"><b> Autor:</b> </td> <td width="404"> <input type="text" name="email" value="<%=(Recordset1.Fields.Item("autor").Value)%>" size="47"> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"><b>E-mail do Responsável: </b> </td> <td width="404"> <input type="text" name="tel1" value="<%=(Recordset1.Fields.Item("email").Value)%>" size="47"> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"><b> Observações e Motivos:</b> </td> <td width="404"> <textarea TYPE="text" NAME="obs" rows="5" cols="78" value="<%=(Recordset1.Fields.Item("obs").Value)%>"></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"></td> <td width="404"> </td> </tr> <tr valign="baseline"> <td nowrap align="left" width="193"> </td> <td width="404"> <p align="center"> <input type="submit" value="( Atualizar )"> </p> </td> </tr> </table> <input type="hidden" name="MM_update" value="true"> <input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("codigo").Value %>"></form><%@LANGUAGE="VBSCRIPT"%><!--#include file="Connections/avis_manut.asp" --><%' ******************** WWW.COMERCIALWEB.COM.BR *********************' * Este sistema foi desenvolvido por: www.comercialweb.com.br *' * desenvolvimentos loja virtual dominio e hospedagem. *' * E-mail comercial@comercialweb.com.br *' * caso tenha alguma dúvida leia o arquivo configuração.txt *' * ou envie um E-mail: yy200@ig.com.br a/c Luciano *' ******************************************************************MM_editAction = CStr(Request("URL"))If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Request.QueryStringEnd If' boolean to abort record editMM_abortEdit = false' query string to executeMM_editQuery = ""%><%' *** Update Record: set variablesIf (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then MM_editConnection = MM_avis_manut_STRING MM_editTable = "tabela1" MM_editColumn = "codigo" MM_recordId = "" + Request.Form("MM_recordId") + "" MM_editRedirectUrl = "confirma_atualizacao.asp" MM_fieldsStr = "servidor|value|sistema|value|dia|value|inicio|value|termino|value|autor|value|email|value|obs|value" MM_columnsStr = "|servidor|',none,''|sistema|',none,''|dia|',none,''|inicio|',none,''|termino|',none,''|autor|',none,''|email|',none,''|obs|',none,NULL" ' create the MM_fields and MM_columns arrays MM_fields = Split(MM_fieldsStr, "|") MM_columns = Split(MM_columnsStr, "|") ' set the form values For i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_fields(i+1) = CStr(Request.Form(MM_fields(i))) Next ' 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 IfEnd If%><%' *** Update Record: construct a sql update statement and execute itIf (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then ' create the sql update statement MM_editQuery = "update " & MM_editTable & " set " For i = LBound(MM_fields) To UBound(MM_fields) Step 2 FormVal = MM_fields(i+1) MM_typeArray = Split(MM_columns(i+1),",") Delim = MM_typeArray(0) If (Delim = "none") Then Delim = "" AltVal = MM_typeArray(1) If (AltVal = "none") Then AltVal = "" EmptyVal = MM_typeArray(2) If (EmptyVal = "none") Then EmptyVal = "" If (FormVal = "") Then FormVal = EmptyVal Else If (AltVal <> "") Then FormVal = AltVal ElseIf (Delim = "'") Then ' escape quotes FormVal = "'" & Replace(FormVal,"'","''") & "'" Else FormVal = Delim + FormVal + Delim End If End If If (i <> LBound(MM_fields)) Then MM_editQuery = MM_editQuery & "," End If MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal Next MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId If (Not MM_abortEdit) Then ' execute the update 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 IfEnd If%><%Dim Recordset1__CodigoRecordset1__Codigo = "0"if (request.querystring("tabela1") <> "") then Recordset1__Codigo = request.querystring("tabela1") %><%set Recordset1 = Server.CreateObject("ADODB.Recordset")Recordset1.ActiveConnection = MM_avis_manut_STRINGRecordset1.Source = "SELECT codigo , servidor, sistema, dia , inicio, termino, autor, email, obs FROM tabela1 WHERE codigo = " + Replace(Recordset1__Codigo, "'", "''") + ""Recordset1.CursorType = 0Recordset1.CursorLocation = 2Recordset1.LockType = 3Recordset1.Open()Recordset1_numRows = 0%><p> </p></body></html><%Recordset1.Close()%> Quote Link to comment Share on other sites More sharing options...
Question
Danilo Piovani
Falae galera ...
vocês podem me dar um exemplo de um update no BD Access ...
No caso seria via formulário ...
Valeu { } ...
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.