Jump to content
Fórum Script Brasil
  • 0

comando insert into


satoshy

Question

boa tarde a todos !

estou fazendo agora a parte de cadastro, e para isso estou usando o Insert Into ...

segue o codigo abaixo :

If r.EOF then 
        If Request.Form("p1") = Request.Form("p2") then 
        c.Execute "Insert Into Tabela1(Nome,Usuario,Senha,E-mail,Telefone) values ('"& Request.Form("t1") &"', '"& Request.Form("t2")&"', '"& Request.Form("p1") &"', '"& Request.Form("t4") &"', '"& Request.Form("t3") &"'" 
        Response.Write "OK" 
        Else 
        Response.Write "Fail" 
        End If 
Else 
Response.write "Usuario já existe" 
End If
e o erro esta nessa linha :
c.Execute "Insert Into Tabela1(Nome,Usuario,Senha,E-mail,Telefone) values ('"& Request.Form("t1") &"', '"& Request.Form("t2")&"', '"& Request.Form("p1") &"', '"& Request.Form("t4") &"', '"& Request.Form("t3") &"'"

e o erro é :

Microsoft Office Access Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/pagina_asp/cadastro.asp, line 18

tabela :

Database1.accdb

Tabela1

Chave primaria : Código = auto num.

Nome = texto

Usuario = texto

Senha = texto

E-mail = texto

Telefone = texto

teste_cadastro.html

t1 = text (nome)

t2 = text (usuario)

t3 = text (telefone)

t4 = text (e-mail)

p1 = password (senha)

p2 = password (confirmar senha)

alguém sabe aonde estou errando ??

Att.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

faltou fechar o final

c.Execute "Insert Into Tabela1(Nome,Usuario,Senha,E-mail,Telefone) values ('"& Request.Form("t1") &"', '"& Request.Form("t2")&"', '"& Request.Form("p1") &"', '"& Request.Form("t4") &"', '"& Request.Form("t3") &"')"
Link to comment
Share on other sites

  • 0

Faltaram os parenteses em vermelho

c.Execute("Insert Into Tabela1(Nome,Usuario,Senha,E-mail,Telefone) values ('"& Request.Form("t1") &"', '"& Request.Form("t2")&"', '"& Request.Form("p1") &"', '"& Request.Form("t4") &"', '"& Request.Form("t3") &"')")

qualquer coisa imprime a instrução sql para ver se tem erros (abaixo).

vt1 = Request.Form("t1")

vt2 = Request.Form("t2")

vt3 = Request.Form("t3")

vt4 = Request.Form("t4")

vp1 = Request.Form("p1")

vSQL = "Insert Into Tabela1 (Nome, Usuario, Senha, E-mail, Telefone) values ('" & vt1 & "', '" & vt2 & "', '" & vp1 & "', '" & vt4 & "', '" & vt3 & "')"

Response.Write(vSQL)

Response.End

If r.EOF then

If Request.Form("p1") = Request.Form("p2") then

c.Execute(vSQL)

Response.Write "OK"

Else

Response.Write "Fail"

End If

Else

Response.write "Usuario já existe"

End If

Link to comment
Share on other sites

  • 0

tentei por os parenteses

mas deu o mesmo erro ...

eu tirei :

If r.EOF then
    If Request.Form("p1") = Request.Form("p2") then
    c.Execute ("Insert Into Tabela1(Nome,Usuario,Senha,E-mail,Telefone) values ('"& Request.Form("t1") &"', '"& Request.Form("t2")&"', '"& Request.Form("p1") &"', '"& Request.Form("t4") &"', '"& Request.Form("t3") &"')")
    Response.Write "Esta tudo bem"
    Else
    Response.Write "Fail"
    End If
Else
Response.write "Usuario já existe"
End If
e coloquei em cima :
vt1 = Request.Form("t1")
vt2 = Request.Form("t2")
vt3 = Request.Form("t3")
vt4 = Request.Form("t4")
vp1 = Request.Form("p1")

c.execute = "Insert Into Tabela1 (Nome, Usuario, Senha, E-mail, Telefone) values ('" & vt1 & "', '" & vt2 & "', '" & vp1 & "', '" & vt4 & "', '" & vt3 & "')"
Response.Write(vSQL)
Response.End

If r.EOF then
If Request.Form("p1") = Request.Form("p2") then
c.Execute(vSQL)
Response.Write "OK"
Else
Response.Write "Fail"
End If
Else
Response.write "Usuario já existe"
End If

era desse jeito ?

Link to comment
Share on other sites

  • 0

deculpa a todos...

foi uma falta de atenção total de minha parte...

coloquei agora desse jeito :

r.Open "Select * from Tabela1 where Usuario = '"& Request.Form ("p1") &"'",c
vt1 = Request.Form("t1")
vt2 = Request.Form("t2")
vt3 = Request.Form("t3")
vt4 = Request.Form("t4")
vp1 = Request.Form("p1")

vSQL = "Insert Into Tabela1 (Nome, Usuario, Senha, E-mail, Telefone) values ('" & vt1 & "', '" & vt2 & "', '" & vp1 & "', '" & vt4 & "', '" & vt3 & "')"
Response.Write(vSQL)
Response.End

If r.EOF then
If Request.Form("p1") = Request.Form("p2") then
c.Execute(vSQL)
Response.Write "OK"
Else
Response.Write "Fail"
End If
Else
Response.write "Usuario já existe"
End If

e apareceu o response.write vSQL:

Insert Into Tabela1 (Nome, Usuario, Senha, E-mail, Telefone) values ('asdasd', '8000', '123', 'email@email.com.br', '0000-0000')

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...