louvair Postado Março 17, 2004 Denunciar Share Postado Março 17, 2004 Socorro.Como faço para editar um campo de um banco de dados em access numa combobox?At.Louvair Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 ursolouco Postado Março 17, 2004 Denunciar Share Postado Março 17, 2004 Mostra o código: Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 louvair Postado Março 17, 2004 Autor Denunciar Share Postado Março 17, 2004 Não tenho código definito. Mas é só um formulário de edição de dados, sendo que um dos campo é um combobox.Este é o código feito pelo DREAMWEAVER MX<%@LANGUAGE="VBSCRIPT"%><!--#include file="../../../Connections/ConnSolidario.asp" --><%' *** Edit Operations: declare variablesDim MM_editActionDim MM_abortEditDim MM_editQueryDim MM_editCmdDim MM_editConnectionDim MM_editTableDim MM_editRedirectUrlDim MM_editColumnDim MM_recordIdDim MM_fieldsStrDim MM_columnsStrDim MM_fieldsDim MM_columnsDim MM_typeArrayDim MM_formValDim MM_delimDim MM_altValDim MM_emptyValDim MM_iMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))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")) = "form1" And CStr(Request("MM_recordId")) <> "") Then MM_editConnection = MM_ConnSolidario_STRING MM_editTable = "BASE" MM_editColumn = "EMAIL" MM_recordId = "'" + Request.Form("MM_recordId") + "'" MM_editRedirectUrl = "agradecimento.asp" MM_fieldsStr = "txtNome|value|txtDataNas|value|txtEmail|value|txtTelefone|value|txtCidade|value|Estado|value|txtMes|value|txtAno|value|txtInstituicao|value|txtTempo|value|txtTipo|value|txtComent|value" MM_columnsStr = "NOME|',none,''|IDADEANO|',none,''|EMAIL|',none,''|TELEFONE|',none,''|CIDADE|',none,''|ESTADO|',none,''|TEMPO_MES|none,none,NULL|TEMPO_ANO|none,none,NULL|QUAL_INSTITUICAO|',none,''|TEMPO_DISPOE|none,none,NULL|TRABALHAR_REALIZAR|',none,''|COMENTARIOS|',none,''" ' create the MM_fields and MM_columns arrays MM_fields = Split(MM_fieldsStr, "|") MM_columns = Split(MM_columnsStr, "|") ' set the form values For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_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 MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_formVal = MM_fields(MM_i+1) MM_typeArray = Split(MM_columns(MM_i+1),",") MM_delim = MM_typeArray(0) If (MM_delim = "none") Then MM_delim = "" MM_altVal = MM_typeArray(1) If (MM_altVal = "none") Then MM_altVal = "" MM_emptyVal = MM_typeArray(2) If (MM_emptyVal = "none") Then MM_emptyVal = "" If (MM_formVal = "") Then MM_formVal = MM_emptyVal Else If (MM_altVal <> "") Then MM_formVal = MM_altVal ElseIf (MM_delim = "'") Then ' escape quotes MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'" Else MM_formVal = MM_delim + MM_formVal + MM_delim End If End If If (MM_i <> LBound(MM_fields)) Then MM_editQuery = MM_editQuery & "," End If MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_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 rstEdita__MMColParamrstEdita__MMColParam = "1"If (Request.QueryString("txtEmail") <> "") Then rstEdita__MMColParam = Request.QueryString("txtEmail")End If%><%Dim rstEditaDim rstEdita_numRowsSet rstEdita = Server.CreateObject("ADODB.Recordset")rstEdita.ActiveConnection = MM_ConnSolidario_STRINGrstEdita.Source = "SELECT * FROM BASE WHERE EMAIL = '" + Replace(rstEdita__MMColParam, "'", "''") + "'"rstEdita.CursorType = 0rstEdita.CursorLocation = 2rstEdita.LockType = 1rstEdita.Open()rstEdita_numRows = 0%><%Dim rstEstadoDim rstEstado_numRowsSet rstEstado = Server.CreateObject("ADODB.Recordset")rstEstado.ActiveConnection = MM_ConnSolidario_STRINGrstEstado.Source = "SELECT * FROM ESTADO"rstEstado.CursorType = 0rstEstado.CursorLocation = 2rstEstado.LockType = 1rstEstado.Open()rstEstado_numRows = 0%><%If rstEdita.EOF or rstEdita.BOF Then ' Pesquisa não encontrou nada Response.Redirect("inclusao.asp")End If%><html><head><title>Tela de Consulta e Edição</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link href="teste.css" rel="stylesheet" type="text/css"><!--#include file="../teste/bibjavas.js" --><!--#include file="../solidario/dataformat.asp" --></head><body><form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1"> <p> </p> <table width="85%" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#D8ECF5"> <tr> <td width="38%"> <div align="left"><strong><font size="2" face="Arial, Helvetica, sans-serif"> <font color="#FF0000">*</font></font><font size="2"><font color="#FF0000"> <font face="Arial, Helvetica, sans-serif">Campos Obrigatórios </font></font></font></strong></div></td> <td colspan="2"> </td> </tr> <tr> <td><div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Nome</font></div></td> <td colspan="2"><input name="txtNome" type="text" id="txtNome2" value="<%= UCase((rstEdita.Fields.Item("NOME").Value)) %>" size="40" maxlength="40" onChange="javascript:this.value=this.value.toUpperCase();"> <font color="#FF0000"> <strong><font color="#FF0000">*</font></strong><font color="#FF0000"></font></font></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Data de nascimento</font></div></td> <td colspan="2"> <input name="txtDataNas" type="text" id="txtDataNas" value="<%=(rstEdita.Fields.Item("IDADEANO").Value)%>" onFocus="javascript:vDateType='3'" onBlur="DateFormat(this,this.value,event,true,'3')" onKeyUp="DateFormat(this,this.value,event,false,'3')" size="12" maxlength="12"> <font color="#FF0000"><strong>*</strong></font></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">E-mail</font></div></td> <td colspan="2"> <input name="txtEmail" type="text" id="txtEmail" value="<%=(rstEdita.Fields.Item("EMAIL").Value)%>" size="30" maxlength="30"> <font color="#FF0000"><strong>*</strong></font></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Telefone</font></div></td> <td colspan="2"> <input name="txtTelefone" type="text" id="txtTelefone" value="<%=(rstEdita.Fields.Item("TELEFONE").Value)%>" size="20" maxlength="20" onkeypress="return txtBoxFormat(document.form1, 'txtTelefone', '(99)9999-9999999', event);"></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Cidade:</font></div></td> <td colspan="2"> <input name="txtCidade" type="text" id="txtCidade" value="<%=(rstEdita.Fields.Item("CIDADE").Value)%>" size="30" maxlength="30" onChange="javascript:this.value=this.value.toUpperCase();"> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> </font></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Estado:</font></div></td> <td width="28%"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><strong><font size="2" face="Arial, Helvetica, sans-serif"><%=(rstEdita.Fields.Item("ESTADO").Value)%></font></strong> </font> </td> <td width="34%"><strong><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> <select name="Estado" size="1" id="Estado"> <% Do While Not rstEstado.EOF %> <option value="<% = rstEstado("uf")%>"><% = rstEstado("estado")%> </option> <% rstEstado.MoveNext LOOP %> </select> </font></strong></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Modalidade Engenharia:</font></div></td> <td><div align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> </font><font size="2" face="Arial, Helvetica, sans-serif"><strong><font size="2" face="Arial, Helvetica, sans-serif"><%=(rstEdita.Fields.Item("MOD_ENGENHARIA").Value)%></font></strong></font></div></td> <td><strong><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> </font></strong></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Data de Conclusão do Curso</font></div></td> <td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif"> <input name="txtMes" type="text" id="txtMes" value="<%=(rstEdita.Fields.Item("TEMPO_MES").Value)%>" size="3" maxlength="2"> / <input name="txtAno" type="text" id="txtAno" value="<%=(rstEdita.Fields.Item("TEMPO_ANO").Value)%>" size="5" maxlength="4"> (Mês/Ano) </font></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Realiza, ou já realizou trabalho voluntário?</font></div></td> <td colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> </font><font size="2" face="Arial, Helvetica, sans-serif"><strong><%=(rstEdita.Fields.Item("TRAB_VOLUNTARIO").Value)%></strong></font></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Junto a qual instituição?</font></div></td> <td colspan="2"><div align="left"><font size="2" face="Arial, Helvetica, sans-serif"> <textarea name="txtInstituicao" cols="30" rows="3" id="txtInstituicao" onChange="javascript:this.value=this.value.toUpperCase();"><%=(rstEdita.Fields.Item("QUAL_INSTITUICAO").Value)%></textarea> </font></div></td> </tr> <tr> <td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Que tempo dispõe para trabalhos voluntários?</font></div></td> <td colspan="2"><div align="left"><font size="1" face="Arial, Helvetica, sans-serif"> <input name="txtTempo" type="text" id="txtTempo" value="<%=(rstEdita.Fields.Item("TEMPO_DISPOE").Value)%>" size="3" maxlength="3"> horas </font></div></td> </tr> <tr> <td><div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Período:</font></div></td> <td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif"><strong><%=(rstEdita.Fields.Item("CLASS_TEMPO").Value)%></strong></font></td> </tr> <tr> <td> <div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><font size="1">Que tipo de trabalho gostaria de realizar?</font></font></div></td> <td colspan="2"><div align="left"><font size="2" face="Arial, Helvetica, sans-serif"> <textarea name="txtTipo" cols="30" rows="3" id="txtTipo"><%=(rstEdita.Fields.Item("TRABALHAR_REALIZAR").Value)%></textarea> </font></div></td> </tr> <tr> <td colspan="3"><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><font size="1"></font></font></div> <div align="right"><font size="2" face="Arial, Helvetica, sans-serif"></font></div> <div align="center"><font size="1" face="Arial, Helvetica, sans-serif">Outros Comentários </font></div></td> </tr> <tr> <td colspan="3" align="center"> <p> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> <textarea name="txtComent" cols="100" rows="5" id="txtComent" style="font-family: Verdana; font-size: xx-small""><%=(rstEdita.Fields.Item("COMENTARIOS").Value)%></textarea> </font> </p> <font size="2" face="Arial, Helvetica, sans-serif"> </font> <font size="2" face="Arial, Helvetica, sans-serif"> </font></td> </tr> <tr> <td colspan="3"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><font size="1"></font></font><font size="2" face="Arial, Helvetica, sans-serif"></font><font size="2" face="Arial, Helvetica, sans-serif"> <input type="submit" name="Submit" value="Alterar" onClick="MM_validateForm('Nome','','R','txtEmail','','RisEmail','txtMes','','NinRange1:12','txtAno','','NinRange1900:2005','txtTempo','','RisNum');return document.MM_returnValue"> <br> <br> </font></div></td> </tr> </table> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="MM_recordId" value="<%= rstEdita.Fields.Item("EMAIL").Value %>"></form><p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#000000">Obs.: Os dados constantes deste formulário permanecerão em absoluto sigilo.</font><font size="2" face="Arial, Helvetica, sans-serif" color="#000000"></font></p><p> </p></body></html><%rstEdita.Close()Set rstEdita = Nothing%><%rstEstado.Close()Set rstEstado = Nothing%> Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
louvair
Socorro.
Como faço para editar um campo de um banco de dados em access numa combobox?
At.
Louvair
Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.