Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

delgisa

Não consigo gravar

Recommended Posts

Olá turma do Imasters, olha eu novamente.... Parece que a coisa tá feia pro meu lado, só dá erro em meus projetos, rsrsrsrsrssrr....

 

É o seguinte, estou com problemas agora em outra página para gravar dados no access.

 

Tenho um formulário que deveria gravar os dados no banco. Veja meu escript:

 

<!--#include file="includes/config.asp"-->
<!--#include file="includes/abrebanco.asp"-->
<!--#include file="travar.asp"-->

<%
'sql_categ = "SELECT DISTINCT categoria FROM imoveis"
'sql_tipo = "SELECT DISTINCT tipo FROM tipos"
'sql_local = "SELECT DISTINCT local FROM locais"
'sql_cidade = "SELECT DISTINCT cidade FROM cidade"
'Set exe_categ = banco.execute(sql_categ)
'Set exe_tipo = banco.execute(sql_tipo)
'Set exe_local = banco.execute(sql_local)
'Set exe_cidade = banco.execute(sql_cidade)
%>
<head>
<title><%=titulo%></title>
<link href="<%=local%>includes/styles/link.css" rel="stylesheet" type="text/css">
<style>
<!--
font		 { font-family: Arial; font-size: 11 }
-->
</style>
</head>

<body bgcolor="<%=fundo%>" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="778" height="0" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
	<td height="77"><!--include file="includes/barra.asp"--></td>
  </tr>
  <tr>
	<td height="249"><table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr>
		  <td width="56" height="260" valign="top" rowspan="2" bgcolor="#EBEBEB"></td>
		  <td width="570" height="260" rowspan="2" valign="top">
			<div align="center">
			  <center><table width="97%" border="0" cellpadding="0" cellspacing="0">
			  <tr>
				<%
				 If IsEmpty( Request.Form("submit") ) Then
				%>

				<td height="0" valign="top"><form method=post action="<%=Request.ServerVariables("script_name")%>">
					<p> </p>
					</tr>
			</table>
			
	  <table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr> 
		  <td height="0" colspan="2"><font size="8" face="Arial, Helvetica, sans-serif"><b>Administrar 
			Imobiliária: Cadastro de Imóvel</b></font></td>
		</tr>
		<tr> 
		  <td height="0" colspan="2"><p> </p>
				  <p><font size="2" face="Arial, Helvetica, sans-serif"><b>***Cadastre 
					uma nova Enquete:</b></font></p></td>
		</tr>
		<tr> 
		  <td>  </td>
		</tr>
		<tr> 
		  <td height="0" colspan="2"><div align="center"></div></td>
		</tr>
		
		<tr> 
		  <td width="30%"><%=fonte02%>Questão</td>
				<td width="70%"><textarea name="Question" cols="14" rows="5"></textarea></td>
		</tr>
		
		<tr> 
		  <td width="30%"><%=fonte02%>Alternativa 1:</td>
		  <td width="70%"><input name="Selection_1" type="text" maxlength="50" class="formindex" size="55"></td>
		</tr>
		<tr> 
		  <td width="30%"><%=fonte02%>Alternativa 2:</td>
		  <td width="70%"><input name="Selection_2" type="text" maxlength="50" class="formindex" size="55"></td>
		</tr>
		<tr> 
		  <td width="30%"><%=fonte02%>Alternativa 3:</td>
		  <td width="70%"><input name="Selection_3" type="text" maxlength="50" class="formindex" size="55"></td>
		</tr>
		
		<tr> 
		  <td width="30%"><%=fonte02%>Alternativa 4:</td>
		  <td width="70%"><input name="Selection_4" type="text" maxlength="50" class="formindex" size="55"></td>
		</tr>
		<tr> 
		  <td width="30%"><%=fonte02%>Alternativa 5:</td>
		  <td width="70%"><input name="Selection_5" type="text" maxlength="50" class="formindex" size="55"></td>
		</tr>
		<tr> 
		  <td width="30%"><%=fonte02%>Alternativa 6:</td>
		  <td width="70%"><input name="Selection_6" type="text" maxlength="50" class="formindex" size="55"></td>
		</tr>
		<tr> 
		  <td width="30%"><%=fonte02%>Data atual</td>
		  <td width="70%"><input name="Date" type="text" class="formindex" value="<%=date%>" size="55" maxlength="50" ></td>
		</tr>
		 
		<tr> 
		<tr> 
		  <td> </td>
		  <td><input name="reset" type="reset" style="font-family: Arial; font-size: 11" value="Limpar"> 
			   <input type="submit" name=submit value="OK" style="font-family: Arial; font-size: 11"></td>
		</tr>
		<tr> 
		  <td colspan="2"> </td>
		</tr>
		<tr> 
		  <td colspan="2"><div align="center"><%=fonte01%><a href="java script:window.history.go(-1)">Voltar</a></div></td>
		</tr>
		<%
Else
  If Not IsEmpty(Request.Form("submit")) AND Trim(Request.Form("Question")) <> ""  Then
	ComandoSQL = "INSERT INTO tblPolls (Question, Selection_1, Selection_2, Selection_3, Selection_4, Selection_5, Selection_6, date)"
	ComandoSQL = ComandoSQL & " VALUES ("
	ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Question")) & "',"
	ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Selection_1")) & "',"
	ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Selection_2")) & "',"
	ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Selection_3")) & "',"
	ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Selection_4")) & "',"
	ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Selection_5")) & "',"
	ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Selection_6")) & "',"
	ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Date")) & "')"
	'response.Write(comandoSQL)
	'response.End()
	Set bd = banco.Execute(ComandoSQL)
	banco.Close
	Set bd = Nothing
	Set banco = Nothing

%>
		<center>
		  <font face="Arial" size="2"><br>
		  Os dados foram enviados com sucesso! <br>
		  <a href="identificado.asp"><b>Clique aqui</b></a> para continuar</font>
		</center>
		<%
  Else
%>
		<center>
		  <font face="Arial" size="2"><br>
		  Atenção: Alguns dados necessário não foram preenchidos corretamente 
		  <br>
		  <a href="java script:history.go(-1)"><b>Clique aqui</b></a> para voltar</font>
		</center>
		<%
  End If
End If
%>
	  </table>
	</center>
			</div>
		  </td>
		  <td width="154" valign="top"><!--include file="includes/menuesq.asp"-->


[font="Arial Black"][/font]Só que acontece um erro:
Microsoft OLE DB Provider For ODBC Drivers (0x80040E14) [Microsoft] [Drivers ODBC para Microsoft Acess] Erro de Sintaxe na instrução INSERT INTO Line 126


Veja os campos que eu tenho na tabela:
id_no = Auto numeração
Question = Texto
Selection_1 = Texto
Selection_2 = Texto
Selection_3 = Texto
Selection_4 = Texto
Selection_5 = Texto
Selection_6 = Texto
Votes_1 = Número
Votes_2 = Número
Votes_3 = Número
Votes_4 = Número
Votes_5 = Número
Votes_6 = Número
Votes_7 = Número
Date = Texto

 

Por favor, aonde estou errando.....

 

Grato

 

jardel

Compartilhar este post


Link para o post
Compartilhar em outros sites

Qual o erro exatamente?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Qual o erro exatamente?

 

 

O erro é este:

 

Erro de Sintaxe na instrução INSERT INTO Line 126

 

 

grato

 

jardel

Compartilhar este post


Link para o post
Compartilhar em outros sites

O que tem na linha?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Posta o resultado disso:

response.Write(comandoSQL)

Compartilhar este post


Link para o post
Compartilhar em outros sites

isso poste o resultado do que aparecer

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.