Ir para conteúdo

POWERED BY:

Arquivado

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

renataferro

Estou com um erro!

Recommended Posts

Oii, sou iniciante em asp e estou fazendo um cadastro de estados e quando eu vou apertar no botão salvar ele lança este erro:

 

 

Tipo de erro:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ','./eccos/adm_estado_s.asp, line 93

 

 

a linha 93 esta executando o select altera que é este:

 

 

altera = "insert into ec_estados (i_empresa, i_estado, nome, sigla, pais, usuario, dt_sistema) values (" & Session("i_empresa") & ", "&id&",'" & Session("nome") & ","  &Session("sigla") & "," & Session ("pais") & "',"& Session("usuario") &", GETDATE() )"	elseif Session("type") = "atualiza" then 	altera = "update ec_estados set nome = '" & Session("nome") & ",sigla="& Session("sigla") & "', usuario="& Session("usuario") &", dt_sistema= GetDate() where i_empresa="&session("i_empresa")&" and i_estado= "& id

Compartilhar este post


Link para o post
Compartilhar em outros sites

altere para isso

ASP
altera = "update ec_estados set nome = '" & Session("nome") & "',sigla='"& Session("sigla") & "', usuario='"& Session("usuario") &"', dt_sistema= GetDate() where i_empresa='"&session("i_empresa")&"' and i_estado= "& id

veja que coloquei ' em alguns locais, verifique se o campo na tabela é do tipo numero, se for deve retirar as pastas ' correspondente ao campo

Compartilhar este post


Link para o post
Compartilhar em outros sites

não solucionou,

 

a tabela estados tem os seguintes campos: i_empresa, i_estado, nome, sigla, pais, i_ususario, dt_sistema

 

 

o erro continuaaa

 

o código inteiro aí:

 

 

ASP
<%
call Seguranca()
session("erro")=""
Session("type") = replace(request.form("type"),"'","")
 
if Session("type") = "insere" then
elseif Session("type") = "atualiza" then
'Pega código do estado
id = trim(replace(request.form("id"),"'",""))
if id= empty then
%>
<script>
alert("Erro ao buscar o Estado ! ");
history.back(-1)
</script>
<%
response.end
end if
if not isnumeric(id) then
%>
<script>
alert("Erro ao buscar o Estado ! ");
history.back(-1)
</script>
<%
response.end
end if
else
response.redirect("adm_estado.asp")
end if
 
Session("nome") = replace(request.form("nome"),"'","")
 
if Session("nome") = empty then
%>
<script>
alert("É obrigatório preenchimento do campo Nome ! ");
history.back(-1)
</script>
<%
response.end
end if
if len(Session("nome"))<3 then
%>
<script>
alert("O campo Nome deve ter no mínimo 3 caracteres !");
history.back(-1)
</script>
<%
response.end
end if
 
 
 
Dim altera, ors
 
if Session("type") = "insere" then
Call Abre_db()
 
id = 0
set ors = conn.execute("select max(i_estado) as proximo from ec_estados where i_empresa="&session("i_empresa"))
if ors.eof then
set ors=nothing
Call Fecha_db()
else
if not isnull(ors("proximo")) then
id = ors("proximo")
end if
set ors=nothing
Call Fecha_db()
end if
id = id + 1
 
altera = "insert into ec_estados (i_empresa, i_estado, nome, sigla, pais, usuario, dt_sistema) values (" & Session("i_empresa") & ", "&id&",'" & Session("nome") & "," &Session("sigla") & "," & Session ("pais") & "',"& Session("usuario") &", GETDATE() )"
elseif Session("type") = "atualiza" then
altera = "update ec_estados set nome = '" & Session("nome") & Session("sigla") & Session("pais") "', usuario="& Session("usuario") &", dt_sistema= GetDate() where i_empresa="&session("i_empresa")&" and i_estado= "& id
 
else
%>
<script>
alert("Operação não selecionada !");
history.back(-1)
</script>
<%
response.end
end if
 
'------------------------------------
 
 
Call Abre_db()
 
set ors = conn.execute(altera)
set ors=nothing
 
Call Fecha_db()
 
response.redirect "adm_estado.asp"
%>
<link href="estilos.css" rel="stylesheet" type="text/css">
 
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<p class="texto1">Aguarde um instante por favor...</p>
</div></td>
</tr>
</table>

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.