Ir para conteúdo
Fórum Script Brasil
  • 0

Editar Campo De Bd Numa Combobox


louvair

Pergunta

2 respostass a esta questão

Posts Recomendados

  • 0

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 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 = ""

%>

<%

' *** Update Record: set variables

If (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 If

End If

%>

<%

' *** Update Record: construct a sql update statement and execute it

If (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 If

End If

%>

<%

Dim rstEdita__MMColParam

rstEdita__MMColParam = "1"

If (Request.QueryString("txtEmail") <> "") Then

rstEdita__MMColParam = Request.QueryString("txtEmail")

End If

%>

<%

Dim rstEdita

Dim rstEdita_numRows

Set rstEdita = Server.CreateObject("ADODB.Recordset")

rstEdita.ActiveConnection = MM_ConnSolidario_STRING

rstEdita.Source = "SELECT * FROM BASE WHERE EMAIL = '" + Replace(rstEdita__MMColParam, "'", "''") + "'"

rstEdita.CursorType = 0

rstEdita.CursorLocation = 2

rstEdita.LockType = 1

rstEdita.Open()

rstEdita_numRows = 0

%>

<%

Dim rstEstado

Dim rstEstado_numRows

Set rstEstado = Server.CreateObject("ADODB.Recordset")

rstEstado.ActiveConnection = MM_ConnSolidario_STRING

rstEstado.Source = "SELECT * FROM ESTADO"

rstEstado.CursorType = 0

rstEstado.CursorLocation = 2

rstEstado.LockType = 1

rstEstado.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>&nbsp;</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">&nbsp;<font color="#FF0000">*</font></font><font size="2"><font color="#FF0000">&nbsp;<font face="Arial, Helvetica, sans-serif">Campos

Obrigat&oacute;rios </font></font></font></strong></div></td>

<td colspan="2">&nbsp; </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();">

&nbsp;<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">

&nbsp;<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">

&nbsp;<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">&nbsp;

</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&atilde;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&ecirc;s/Ano) </font></td>

</tr>

<tr>

<td> <div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Realiza,

ou j&aacute; realizou trabalho volunt&aacute;rio?</font></div></td>

<td colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">&nbsp;

</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&ccedil;&atilde;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&otilde;e para trabalhos volunt&aacute;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&iacute;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&aacute;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">&nbsp;</font> <font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</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&aacute;rio permanecer&atilde;o em absoluto

sigilo.</font><font size="2" face="Arial, Helvetica, sans-serif" color="#000000"></font></p>

<p>&nbsp;</p>

</body>

</html>

<%

rstEdita.Close()

Set rstEdita = Nothing

%>

<%

rstEstado.Close()

Set rstEstado = Nothing

%>

Link para o comentário
Compartilhar em outros sites

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.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...