Inquiridor
edição de campo text

Pergunta
-
Olá, trabalho com ASP e banco de Dados SQL 2000. Estou tendando fazer a edição e consulta de um campo do tipo text, entretanto quando executo a rotina de buscar do campo no banco de dados para a edição e posteriormente realizar o UPDATE, simplesmente não vem o conteúdo do campo tipo text, entretanto, os demais campos aparecem o conteúdo normalmente.
PS: na inserção de dados funciona normalmente, apenas para a edição e consulta é que o campo não retorna na tela.
Se alguém puder me ajudar eu agradeço.
Todas as Respostas
-
-
Segue abaixo o código da página em ASP VBScript
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/SRH2.asp" -->
<%
' *** Edit Operations: declare variablesDim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmdDim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordIdDim 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_iMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If' boolean to abort record edit
MM_abortEdit = false' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variablesIf (CStr(Request("MM_insert")) = "form2") Then
MM_editConnection = MM_SRH2_STRING
MM_editTable = "dbo.Tb_AlteracaoOficial"
MM_editRedirectUrl = "sucessoPRO.asp"
gravalog = "sim"
' *** grava o LOG do usuário
IF gravalog = "sim" THEN
Pagina_Acesso="PRO/inc_fic_info.asp "
Usuario_Acesso=Session("MM_Username")
Data_Acesso=date() + time()
Set rs_log = Server.CreateObject("ADODB.Recordset")
rs_log.ActiveConnection = Cn
sedQuery = "Insert Tb_log Select '"&Usuario_Acesso&"','"&Pagina_Acesso&"'+'"&request("realt")&"','"&Data_Acesso&"'"
set rs_log = Cn.Execute(sedQuery)
END IF
MM_fieldsStr = "quadro|value|grad|value|OPM|value|inf_quad|value|quadri_ano|value|periodo|value|1parte|value|2parte|value|parte3|value|parte32|value|ReOfInf|value|realt|value"
MM_columnsStr = "Quad_Cod|none,none,NULL|Grad_Cod|none,none,NULL|Opm_Cod|none,none,NULL|Alt_Quadri|none,none,NULL|Alt_QuadriAno|none,none,NULL|Alt_Periodo|',none,''|Alt_Parte1|',none,''|Alt_Parte2|',none,''|Alt_Parte3|',none,''|Alt_Parte3Cont|',none,''|Alt_ReResp|none,none,NULL|Pm_Re|none,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 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
%>
<%
' *** Insert Record: construct a sql insert statement and execute itDim MM_tableValues
Dim MM_dbValuesIf (CStr(Request("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
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_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.CloseIf (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End IfEnd If
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="00,20"
MM_authFailedURL="AcessoNegado.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<!--#include file="Pg_Func.asp"-->
<%
Dim rs_pm__MMColParam
rs_pm__MMColParam = "0"
If (Request.Form("RE") <> "") Then
rs_pm__MMColParam = Request.Form("RE")
End If
%>
<%
Dim rs_pm
Dim rs_pm_numRowsSet rs_pm = Server.CreateObject("ADODB.Recordset")
rs_pm.ActiveConnection = MM_SRH2_STRING
rs_pm.Source = "SELECT a.pm_re, a.pm_nom, c.grad_abr, c.grad_cod, d.quad_cod FROM Tb_PolicialMilitar a,tb_promocao b, tb_graduacao c, tb_tipoquadro d WHERE a.Pm_Re = '" + Replace(rs_pm__MMColParam, "'", "''") + "' and a.pm_re=b.pm_re and a.quad_cod=d.quad_cod and b.grad_cod = (select min(z.grad_cod) FROM tb_promocao z WHERE z.pm_re=a.pm_re) and b.grad_cod = c.grad_cod"
rs_pm.CursorType = 0
rs_pm.CursorLocation = 2
rs_pm.LockType = 1
rs_pm.Open()rs_pm_numRows = 0
%>
<%
Dim rs_quadro
Dim rs_quadro_numRowsSet rs_quadro = Server.CreateObject("ADODB.Recordset")
rs_quadro.ActiveConnection = MM_SRH2_STRING
rs_quadro.Source = "SELECT * FROM dbo.Tb_TipoQuadro"
rs_quadro.CursorType = 0
rs_quadro.CursorLocation = 2
rs_quadro.LockType = 1
rs_quadro.Open()rs_quadro_numRows = 0
%>
<%
Dim rs_opm
Dim rs_opm_numRowsSet rs_opm = Server.CreateObject("ADODB.Recordset")
rs_opm.ActiveConnection = MM_SRH2_STRING
rs_opm.Source = "SELECT * FROM dbo.Tb_Opm ORDER BY Opm_Abr ASC"
rs_opm.CursorType = 0
rs_opm.CursorLocation = 2
rs_opm.LockType = 1
rs_opm.Open()rs_opm_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ficha de Alteração</title>
<style type="text/css">
<!--
.titulo {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
color: #003399;
font-weight: bold;
}
.campo {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
font-weight: bold;
}
.alerta {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #003399;
font-weight: bold;
}
.campos2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
body {
background-color: #CCCCCC;
}
.style1 {font-size: 10px}
-->
</style>
<script language="Javascript1.2">
_editor_url = "";
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script>
</head>
<script language="javascript">
function alerta()
{///////////////////////////////////////////////
if (document.form2.OPM.value == "")
{
alert("Informe a OPM!");
document.form2.OPM.focus()
return false
}
if (document.form2.inf_quad.value == "")
{
alert("Informe o quadrimestre!");
document.form2.inf_quad.focus()
return false
}
if (document.form2.quadri_ano.value == "")
{
alert("Informe o ano a que o quadrimestre se refere!");
document.form2.quadri_ano.focus()
return false
}
if (document.form2.periodo.value == "")
{
alert("Informe o período!");
document.form2.periodo.focus()
return false
}
if (document.form2.CargPeriodo.value == "")
{
alert("Informe os cargos desempenhados durante o período, se por acaso não houver, informe que não houve!");
document.form2.CargPeriodo.focus()
return false
}
if (document.form2.ReOfInf.value == "1000")
{
alert("Informe o RE do Oficial informante!");
document.form2.ReOfInf.focus()
return false
}
var cont=0;if (document.form2.LAVerd.value !=0)
{
cont=cont+1}
if (document.form2.NResp.value != 0)
{
cont=cont+1
}
if (document.form2.CompFaceSit.value != 0)
{
cont=cont+1}
if (document.form2.EnergPersev.value != 0)
{
cont=cont+1}
if (document.form2.CapRacDec.value != 0)
{
cont=cont+1}
if (document.form2.FacExpress.value != 0)
{
cont=cont+1}
if (document.form2.CompDever.value != 0)
{
cont=cont+1}
if (document.form2.EspDici.value != 0)
{
cont=cont+1}
if (document.form2.CorAtitude.value != 0)
{
cont=cont+1}
if (document.form2.EspCamRelHum.value != 0)
{
cont=cont+1}
if (document.form2.ConhProf.value != 0)
{
cont=cont+1}
if (document.form2.ConhGerais.value != 0)
{
cont=cont+1}
if (document.form2.ConhCivil.value != 0)
{
cont=cont+1}
if (document.form2.CapLider.value != 0)
{
cont=cont+1}
if (document.form2.CapJulga.value != 0)
{
cont=cont+1}
if (document.form2.CapPlanej.value != 0)
{
cont=cont+1}
if (document.form2.ProbZelo.value != 0)
{
cont=cont+1}
if (document.form2.CapOrgEfic.value != 0)
{
cont=cont+1}
if (document.form2.CaoInstr.value != 0)
{
cont=cont+1}
if (document.form2.ResFadiga.value != 0)
{
cont=cont+1}
if (document.form2.DispTraba.value != 0)
{
cont=cont+1}
if (cont < 15)
{
alert("deve preencher no mínimo 15 campos!");
document.form2.LAVerd.focus()
return false
}
}
///////////////////////////////////////////////
function SaltaCampo(campo,prox,tammax,teclapres){
var tecla = teclapres.keyCode ? teclapres.keyCode : teclapres.which ? teclapres.which : teclapres.charCode;
vr = document.form2[campo].value;
if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
document.form2[campo].value = vr.substr( 0, vr.length - 1 ); }
else{
tam = vr.length;
if (tecla != 0 && tecla != 9 && tecla != 16 ){
if ( tam == tammax ){
document.form2[prox].select(); //se não quiser o foco, desabilite!
document.form2[prox].focus();
}
}
}
}
</script><body>
<table width="749" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2"><!-- #include file = "topoPRO.asp"--></td>
</tr>
<tr>
<td width="124" valign="top"><!--#include file="menuPRO.asp" -->
</td>
<td width="625" valign="top"><p align="center" class="titulo">Folha de Alteração</p>
<form id="form1" name="form1" method="post" action="inc_fic_alt.asp">
<input type="hidden" name="exibir" value="s" />
<table width="449" border="0" align="center">
<tr>
<td width="88" class="campos2">Digite o R.E: </td>
<td width="157"><label>
<input name="re" type="text" id="re" value="1000" />
</label></td>
<td width="190"><label>
<input type="submit" name="Submit" value="OK" />
</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<p class="alerta" align="center">
<%If request("exibir") = "s" then%>
<%IF rs_pm.Eof Then
response.Write("** RE não cadastrado ou policial sem graduação **")
Else
%>
<% codgrad = rs_pm("grad_cod")
If codgrad > 16 Then
response.Write("** Policial não pertence a nenhum quadro de oficiais **")
Else
%>
</p>
<form ACTION="<%=MM_editAction%>" METHOD="POST" id="form2" name="form2" onSubmit="return alerta ()">
<table width="606" border="0" align="center">
<tr>
<td colspan="2" class="campo"><strong>
<label></label>
</strong>
<label>
<div align="center"><strong><%=(rs_pm.Fields.Item("pm_nom").Value)%> - <%=(rs_pm.Fields.Item("grad_abr").Value)%> RE <%=(rs_pm.Fields.Item("pm_re").Value)%></strong></div></td>
</tr>
<tr>
<td colspan="2" class="campo"><hr align="center" /></td>
</tr>
<tr>
<td width="97" class="campos2"><div align="right">Quadro:</div></td>
<td width="499"><div align="left">
<label>
<select name="quadro" id="quadro">
<%
While (NOT rs_quadro.EOF)
%>
<option value="<%=(rs_quadro.Fields.Item("Quad_Cod").Value)%>" <%If (Not isNull((rs_pm.Fields.Item("quad_cod").Value))) Then If (CStr(rs_quadro.Fields.Item("Quad_Cod").Value) = CStr((rs_pm.Fields.Item("quad_cod").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(rs_quadro.Fields.Item("Quad_Desc").Value)%></option>
<%
rs_quadro.MoveNext()
Wend
If (rs_quadro.CursorType > 0) Then
rs_quadro.MoveFirst
Else
rs_quadro.Requery
End If
%>
</select>
</label>
<input type="hidden" name="grad" value="<%=(rs_pm.Fields.Item("grad_cod").Value)%>" />
</div></td>
</tr>
<tr>
<td class="campos2"><div align="right">O.P.M:</div></td>
<td><select name="OPM" id="OPM">
<option value="">Selecione...</option>
<%
While (NOT rs_opm.EOF)
%>
<option value="<%=(rs_opm.Fields.Item("Opm_Cod").Value)%>"><%=(rs_opm.Fields.Item("Opm_Abr").Value)%></option>
<%
rs_opm.MoveNext()
Wend
If (rs_opm.CursorType > 0) Then
rs_opm.MoveFirst
Else
rs_opm.Requery
End If
%>
</select></td>
</tr>
<tr>
<td class="campos2"><div align="right">Quadrimestre: </div></td>
<td><select name="inf_quad" id="inf_quad">
<option>...</option>
<option value="1">I</option>
<option value="2">II</option>
<option value="3">III</option>
</select>
<span class="campos2">DE</span>
<input name="quadri_ano" type="text" id="quadri_ano" size="5" maxlength="4" /></td>
</tr>
<tr>
<td class="campos2"><div align="right">Período: </div></td>
<td><div align="left">
<label>
<select name="periodo" id="periodo">
<option>Selecione...</option>
<option value="01 FEV A 31 MAI">de 1 de fevereiro à 31 de maio</option>
<option value="01 JUN A 30 SET">de 1 de junho à 30 de setembro</option>
<option value="01 OUT A 31 JAN">de 1 de outubro à 31 de janeiro</option>
</select>
</label>
</div></td>
</tr>
</table>
<table width="606" border="0" align="center">
<tr>
<td><hr align="center" /></td>
</tr>
<tr>
<td valign="top" class="campo"><div align="right" class="style1">
<div align="left">1ª PARTE </div>
</div> <label>
<textarea name="1parte" cols="65" rows="5" id="1parte">INCLUSÃO: Sem Alteração
EXCLUSÃO: Sem Alteração</textarea>
</label></td>
</tr>
<tr>
<td valign="top" class="campos2"><div align="left"><span class="campo">2ª PARTE </span></div>
<textarea name="2parte" cols="65" rows="5" id="2parte">TEMPO COMPUTADO DE EFETIVO SERVIÇO (TC) ......
Arregimentado ....
Não Arregimentado ....
TEMO NãO COMPUTADO (TNC) ....</textarea></td>
</tr>
<tr>
<td valign="top" class="campos2"><div align="left"><span class="campo">3ª PARTE </span></div>
<label>
<textarea name="parte3" cols="65" rows="10" id="parte3" onKeyup="SaltaCampo('parte3','parte32',8000,event)" ></textarea>
</label>
<label>
<textarea name="parte32" cols="65" rows="10" id="parte32" onKeyup="SaltaCampo('parte32','ReOfInf',8000,event)" onfocus=document.getElementById("campo4").disabled=true></textarea>
</label>
</p></td>
</tr>
<tr>
<td class="campos2"> </td>
</tr>
</table>
<table width="606" border="0" align="center">
<tr>
<td width="132" class="campo">Oficial Informante: </td>
<td width="165" class="campo"><label>
<input name="ReOfInf" type="text" id="ReOfInf" value="1000" maxlength="9" />
</label></td>
<td width="295" class="campo"> </td>
</tr>
<tr>
<td colspan="3" class="campo"><hr align="center" /></td>
</tr>
<tr>
<td colspan="3" class="campo"><label>
<div align="center">
<input type="submit" name="Submit2" value="Salvar" />
</div>
</label></td>
</tr>
</table>
<span class="campos2">
<input name="reHidden" type="hidden" id="reHidden" value="<%=(rs_pm.Fields.Item("pm_re").Value)%>" />
</span>
<input name="cod_gradhiddenField" type="hidden" id="cod_gradhiddenField" value="<%=(rs_pm.Fields.Item("grad_cod").Value)%>" />
<input type="hidden" name="realt" value= "<%=rs_pm("pm_re")%>" />
<input type="hidden" name="MM_insert" value="form2">
</form>
<%end if%>
<%end if%>
<%end if%></td>
</tr>
</table>
</body>
</html>
<script language="javascript1.2">
editor_generate('parte3');
</script>
<%
rs_pm.Close()
Set rs_pm = Nothing
%>
<%
rs_quadro.Close()
Set rs_quadro = Nothing
%>
<%
rs_opm.Close()
Set rs_opm = Nothing
%> -
Pelo estilo do código parece ter sido feito no Dreamweaver certo?
Já tentou fazer no ínicio da página response.write em todos os campos pra ter certeza que o problema é com o campo tipo text? Tipo:
Open.rs
Do while not rs.eof
response.write(campo1&","&campo2
rs.movenext
loop
Ou se já tentou alterar o tipo do campo do sql só pra testar, tpo alterar para varchar?
Abraços
Estevam
-
Desde já agradeço a sua ajuda.
respondendo a sua pergunta sim, utilizamos o Dreamweaver para fazer a página em questão.
Já fizemos o procedimento que você está dizendo utilizando o response.write e o campo do tipo varchar aparece o conteúdo, mas quando alteramos para o tipo text o comando response.write náo retorna nenhum valor, como se não tivesse nada no campo, a informação está gravada nele...
-
-