Jump to content


Photo

Página De Edição Com Problemas


  • Faça o login para participar
3 replies to this topic

#1 Marcelo-M4

Marcelo-M4

    Novato no fórum

  • Usuários
  • 10 posts
  • Sexo:Não informado

Posted 06/01/2006, 10:31

Olá a todos,

Estou com um sistema de notícias bem complexo e quase finalizado, estou com problemas na parte de edição da notícia.

O erro que ocorre é na página de edição propriamente dita, após a inclusão da alteração no formulário, clicando no botão para mandar o formulário para o banco
Segue:

Tipo de erro:
Microsoft JET Database Engine (0x80040E14)
Erro de sintaxe na instrução UPDATE.
/sinttel-web/imprensa/edit.asp, line 113


Minha página edit.asp

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/Imprensa06.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
  MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = "";
%>
<%
// *** Update Record: set variables

if (String(Request("MM_update")) == "editarnot" &&
    String(Request("MM_recordId")) != "undefined") {

  var MM_editConnection = MM_Imprensa06_STRING;
  var MM_editTable  = "noticias";
  var MM_editColumn = "ID";
  var MM_recordId = "" + Request.Form("MM_recordId") + "";
  var MM_editRedirectUrl = "indice.asp";
  var MM_fieldsStr = "Principal|value|data|value|assunto|value|email|value|Imagem|value|soutien|value|noticia|value|Resumo|value|user|value";
  var MM_columnsStr = "Principal|none,1,0|data|',none,NULL|assunto|',none,''|email|',none,''|Imagem|',none,''|soutien|',none,''|noticia|',none,''|Resumo|',none,''|user|',none,''";

  // create the MM_fields and MM_columns arrays
  var MM_fields = MM_fieldsStr.split("|");
  var MM_columns = MM_columnsStr.split("|");
 
  // set the form values
  for (var i=0; i+1 < MM_fields.length; i+=2) {
    MM_fields[i+1] = String(Request.Form(MM_fields[i]));
  }

  // append the query string to the redirect URL
  if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
  }
}
%>
<%
var qr_edit__MMColParam = "1";
if (String(Request.QueryString("ID")) != "undefined" &&
    String(Request.QueryString("ID")) != "") {
  qr_edit__MMColParam = String(Request.QueryString("ID"));
}
%>
<%
var qr_edit = Server.CreateObject("ADODB.Recordset");
qr_edit.ActiveConnection = MM_Imprensa06_STRING;
qr_edit.Source = "SELECT * FROM noticias WHERE ID = "+ qr_edit__MMColParam.replace(/'/g, "''") + "";
qr_edit.CursorType = 0;
qr_edit.CursorLocation = 2;
qr_edit.LockType = 1;
qr_edit.Open();
var qr_edit_numRows = 0;
%>
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
  MM_editAction += "?" + Request.QueryString;
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = "";
%>
<%
// *** Update Record: construct a sql update statement and execute it

if (String(Request("MM_update")) != "undefined" &&
    String(Request("MM_recordId")) != "undefined") {

  // create the sql update statement
  MM_editQuery = "update " + MM_editTable + " set ";
  for (var i=0; i+1 < MM_fields.length; i+=2) {
    var formVal = MM_fields[i+1];
    var MM_typesArray = MM_columns[i+1].split(",");
    var delim =    (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
    var altVal =  (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
    var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
    if (formVal == "" || formVal == "undefined") {
      formVal = emptyVal;
    } else {
      if (altVal != "") {
        formVal = altVal;
      } else if (delim == "'") { // escape quotes
        formVal = "'" + formVal.replace(/'/g,"''") + "'";
      } else {
        formVal = delim + formVal + delim;
      }
    }
    MM_editQuery += ((i != 0) ? "," : "") + MM_columns[i] + " = " + formVal;
  }
  MM_editQuery += " where " + MM_editColumn + " = " + MM_recordId;

  if (!MM_abortEdit) {
    // execute the update
    var 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) {
      Response.Redirect(MM_editRedirectUrl);
    }
  }

}
%>
<%
var q_noticias__MMColParam = "1";
if (String(Request.QueryString("ID")) != "undefined" &&
    String(Request.QueryString("ID")) != "") {
  q_noticias__MMColParam = String(Request.QueryString("ID"));
}
%>
<%
var q_noticias = Server.CreateObject("ADODB.Recordset");
q_noticias.ActiveConnection = MM_Imprensa06_STRING;
q_noticias.Source = "SELECT * FROM noticias WHERE ID = "+ q_noticias__MMColParam.replace(/'/g, "''") + "";
q_noticias.CursorType = 0;
q_noticias.CursorLocation = 2;
q_noticias.LockType = 1;
q_noticias.Open();
var q_noticias_numRows = 0;
%>
<html>
<head>
<title>..:: Imprensa Sinttel-DF::.. Edit Not&iacute;cias</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
</head>

<body>
<p><img src="img_base/topo_noticias.gif" width="240" height="35"></p>

<form action="<%=MM_editAction%>" method="POST" name="editarnot" class="style1" id="editarnot">
  <table width="620" align="center">
    <tr valign="baseline">
      <td width="68" align="left" valign="top" nowrap>Principal:</td>
      <td width="249" align="left" valign="top"><input type="checkbox" name="Principal" value=1 ></td>
      <td width="84" align="left" valign="top">Data:</td>
      <td width="199" align="left" valign="top"><input type="text" name="data" value="<%=(qr_edit.Fields.Item("data").Value)%>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td align="left" valign="top" nowrap>Assunto:</td>
      <td align="left" valign="top"><input type="text" name="assunto" value="<%=(qr_edit.Fields.Item("assunto").Value)%>" size="32"></td>
      <td align="left" valign="top">Email:</td>
      <td align="left" valign="top"><input type="text" name="email" value="<%=(qr_edit.Fields.Item("email").Value)%>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td align="left" valign="top" nowrap>Imagem:</td>
      <td align="left" valign="top"><input type="text" name="Imagem" value="<%=(qr_edit.Fields.Item("Imagem").Value)%>" size="32"></td>
      <td align="left" valign="top">Soutien:</td>
      <td align="left" valign="top"><input type="text" name="soutien" value="<%=(qr_edit.Fields.Item("soutien").Value)%>" size="32"></td>
    </tr>
   
    <tr valign="baseline">
      <td align="left" valign="top" nowrap>Noticia:</td>
      <td rowspan="2" align="left" valign="top"><textarea name="noticia" cols="40" rows="20"><%=(qr_edit.Fields.Item("noticia").Value)%></textarea>      </td>
      <td align="left" valign="top">Resumo:</td>
      <td rowspan="2" align="left" valign="top"><textarea name="Resumo" cols="25" rows="10"><%=(qr_edit.Fields.Item("Resumo").Value)%></textarea></td>
    </tr>
    <tr valign="baseline">
      <td align="left" valign="top" nowrap>&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="left" valign="top" nowrap>User:</td>
      <td align="left" valign="top"><input type="text" name="user" value="<%=(qr_edit.Fields.Item("user").Value)%>" size="32">      </td>
      <td align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td colspan="4" align="right" nowrap><input type="submit" value="Editar">      </td>
    </tr>
  </table>
 
<input type="hidden" name="MM_update" value="editarnot">
<input type="hidden" name="MM_recordId" value="<%= qr_edit.Fields.Item("ID").Value %>">
</form>
<p>&nbsp;</p>
</body>
</html>
<%
qr_edit.Close();
%>


Uso o Dreamweaver para criar páginas dinâmicas, conheço um pouco de asp mas não sou desenvolvedor "a mão", desculpe se estou sendo simplista aqui.

#2 alonerusso

alonerusso

    12 Horas

  • Usuários
  • 224 posts
  • Sexo:Masculino

Posted 06/01/2006, 12:08

seria mais facil para te ajudar se vc informar qual é a linha 113 q esta apresentando o erro :huh:
Hay quién apuesta fuerte y decide quererte,
sabiendo lo fácil que resulta perderte...

#3 Marcelo-M4

Marcelo-M4

    Novato no fórum

  • Usuários
  • 10 posts
  • Sexo:Não informado

Posted 06/01/2006, 13:27

Falou, a linha é essa:

  MM_editCmd.Execute();


o Código completo é:

<%
// *** Update Record: construct a sql update statement and execute it

if (String(Request("MM_update")) != "undefined" &&
    String(Request("MM_recordId")) != "undefined") {

  // create the sql update statement
  MM_editQuery = "update " + MM_editTable + " set ";
  for (var i=0; i+1 < MM_fields.length; i+=2) {
    var formVal = MM_fields[i+1];
    var MM_typesArray = MM_columns[i+1].split(",");
    var delim =    (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
    var altVal =  (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
    var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
    if (formVal == "" || formVal == "undefined") {
      formVal = emptyVal;
    } else {
      if (altVal != "") {
        formVal = altVal;
      } else if (delim == "'") { // escape quotes
        formVal = "'" + formVal.replace(/'/g,"''") + "'";
      } else {
        formVal = delim + formVal + delim;
      }
    }
    MM_editQuery += ((i != 0) ? "," : "") + MM_columns[i] + " = " + formVal;
  }
  MM_editQuery += " where " + MM_editColumn + " = " + MM_recordId;

  if (!MM_abortEdit) {
    // execute the update
    var 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) {
      Response.Redirect(MM_editRedirectUrl);
    }
  }

}
%>



#4 Luis Otávio

Luis Otávio

    Super Veterano

  • Usuários
  • 3113 posts
  • Sexo:Masculino
  • Localidade:Porto Alegre
  • Interesses:- Desenvolvimento de aplicações Web com linguagem server-side PHP.

    - Desenvolvimento de aplicações Web com linguagem cliente-side JavaScript, conhecedor e utilizador da biblioteca jQUERY e todas suas características.

    - Otimização de Desempenho aplicados a performance de banco de dados Mysql.

    - Otimização de Desempenho para servidores Web utilizando-se como Webserver NGINX em conjunto com Varnish.

    - Sólidos conhecimentos no CMS WordPress para novas implementações, manutenção, criação e otimização de Plugins.

    - Práticas de atendimento, relacionamento e suporte ao cliente. Trabalhando voltado ao público desde o lançamento da empresa iPORTO.COM, criando laços e vínculos com os mais de Mil clientes da empresa e os braços do grupo.

Posted 07/01/2006, 17:21

vish.. pergunta para o dreamweaver pq ta dando este erro... impossivel de te ajudar com o codigo q o dream gera...
* Otávio Nogueira
* Administração e Configuração de Servidores;
* Combinação Perfeita: NGINX + PHP + VARNISH + HAPROXY
* otavio*iporto.com ~ Tel: +55 51 3366 0177 | +55 51 4063 7343 |
* @iporto




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq