Fórum Erro de sintax #297364
28/09/2005
0
procedure TFrmContainer.BtnSalvarClick(Sender: TObject); var Reg: string; begin if verificaCampos = True and flag1 = False then begin Reg := edit1.Text; Dtmodule.QryContainer.SQL.Clear; Dtmodule.QryContainer.SQL.Add(´Select * from Nvocc_Container´); Dtmodule.QryContainer.SQL.Add(´Where Container = ´ + quotedstr(edit1.Text)); Dtmodule.QryContainer.Open; if Dtmodule.QryContainer.isEmpty then begin Dtmodule.QryContainer.close; Dtmodule.QryContainer.sql.clear; Dtmodule.QryContainer.sql.add(´INSERT INTO Nvocc_Container (Container,tipo,tamanho,Tara) ´); Dtmodule.QryContainer.sql.add(´ VALUES (´ + quotedstr(Edit1.Text) + ´,´ + quotedstr(Edit2.Text) + ´,´ + quotedstr(Edit3.Text) + ´,´ + quotedstr(Edit9.Text) + ´)´); Dtmodule.QryContainer.execsql; Showmessage(´O Registro ( ´ + Reg + ´ ) Foi Inserido com Sucesso´); end else try if Application.MessageBox(´Estes dados já existem, Deseja Salvar mesmo assim?´, ´Confirmação´, MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON2) = idyes then begin Dtmodule.QryContainer.Close; Dtmodule.QryContainer.sql.clear; Dtmodule.QryContainer.sql.add(´UPDATE Nvocc_Container´); Dtmodule.QryContainer.sql.add(´set CONTAINER = ´ + quotedstr(Edit1.Text) + ´,´); Dtmodule.QryContainer.sql.add(´TIPO = ´ + quotedstr(edit2.Text) + ´,´); Dtmodule.QryContainer.sql.add(´TAMANHO = ´ + quotedstr(edit3.Text) + ´,´); Dtmodule.QryContainer.sql.add(´TARA = ´ + quotedstr(edit9.Text)); Dtmodule.QryContainer.sql.Add(´where CONTAINER = ´ + quotedstr(edit1.text)); Dtmodule.QryContainer.execsql; Showmessage(´O Registro ( ´ + Reg + ´ ) Foi Atualizado com Sucesso´); end; except messageBeep(10); end end end;
pois não estou vendo nada de errado com o sql...
Fernando_cunha
Curtir tópico
+ 0Posts
28/09/2005
Rjun
Gostei + 0
28/09/2005
Rjun
procedure TFrmContainer.BtnSalvarClick(Sender: TObject); var Reg: string; begin if (verificaCampos) and (not flag1) then begin Reg := Edit1.Text; Dtmodule.QryContainer.SQL.Clear; Dtmodule.QryContainer.SQL.Add(´Select * from Nvocc_Container´); Dtmodule.QryContainer.SQL.Add(´Where Container = :Container´); Dtmodule.QryContainer.ParamByName(´Container´).Value := Edit1.Text; Dtmodule.QryContainer.Open; if Dtmodule.QryContainer.IsEmpty then begin Dtmodule.QryContainer.Close; Dtmodule.QryContainer.Sql.Clear; Dtmodule.QryContainer.Sql.Add(´INSERT INTO Nvocc_Container (Container, Tipo, Tamanho, Tara) ´); Dtmodule.QryContainer.Sql.Add(´VALUES (:Container, :Tipo, :Tamanho, :Tara)´); Dtmodule.QryContainer.ParamByName(´Container´).Value := Edit1.Text; Dtmodule.QryContainer.ParamByName(´Tipo´).Value := Edit2.Text; Dtmodule.QryContainer.ParamByName(´Tamanho´).Value := Edit3.Text; Dtmodule.QryContainer.ParamByName(´Tara´).Value := Edit9.Text; Dtmodule.QryContainer.ExecSql; Showmessage(´O Registro ( ´ + Reg + ´ ) foi inserido com sucesso´); end else try if Application.MessageBox(´Estes dados já existem. Deseja salvar mesmo assim?´, ´Confirmação´, MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON2) = idyes then begin Dtmodule.QryContainer.Close; Dtmodule.QryContainer.Sql.Clear; Dtmodule.QryContainer.Sql.Add(´UPDATE Nvocc_Container´); Dtmodule.QryContainer.Sql.Add(´SET Container = :Container, Tipo = :Tipo, ´); Dtmodule.QryContainer.Sql.Add(´TAMANHO = :Tamanho, Tara = :Tara ´); Dtmodule.QryContainer.Sql.Add(´where Container = :Container); Dtmodule.QryContainer.ParamByName(´Container´).Value := Edit1.Text; Dtmodule.QryContainer.ParamByName(´Tipo´).Value := Edit2.Text; Dtmodule.QryContainer.ParamByName(´Tamanho´).Value := Edit3.Text; Dtmodule.QryContainer.ParamByName(´Tara´).Value := Edit9.Text; Dtmodule.QryContainer.ExecSql; Showmessage(´O Registro ( ´ + Reg + ´ ) foi atualizado com sucesso´); end; except messageBeep(10); end; end; end;
Gostei + 0
28/09/2005
Fernando_cunha
erro na sintax de insert into
Gostei + 0
28/09/2005
Rjun
Gostei + 0
28/09/2005
Fernando_cunha
eu fiz um teste no button1 e coloquei um comando de insert para inserir qualquer dados... e depois um showmessage.... ele abre o showmessage e nao da o erro de sintax... porem nao insere nada no banco de dados...
olha que coisa estranho....
procedure TFrmArmador.BtnSalvarClick(Sender: TObject); var Reg: string; begin if verificaCampos = True and flag1 = False then begin Reg := edit1.Text; Dtmodule.QryArmador.SQL.Clear; Dtmodule.QryArmador.SQL.Add(´Select * from Nvocc_Armador´); Dtmodule.QryArmador.SQL.Add(´Where Codigo = ´ + quotedstr(edit1.Text)); Dtmodule.QryArmador.Open; if Dtmodule.QryArmador.isEmpty then begin Dtmodule.QryArmador.close; Dtmodule.QryArmador.sql.clear; Dtmodule.QryArmador.sql.add(´INSERT INTO Nvocc_Armador (Codigo, Nome) ´); Dtmodule.QryArmador.sql.add(´ VALUES (´ + quotedstr(Edit1.Text) + ´,´ + quotedstr(Edit2.Text) + ´)´); Dtmodule.QryArmador.execsql; Flag := False; Showmessage(´O Registro ( ´ + Reg + ´ ) Foi Inserido com Sucesso´);
procedure TFrmContainer.BtnSalvarClick(Sender: TObject); var Reg: string; begin if verificaCampos = True and flag1 = False then begin Reg := edit1.Text; Dtmodule.QryContainer.SQL.Clear; Dtmodule.QryContainer.SQL.Add(´Select * from Nvocc_Container´); Dtmodule.QryContainer.SQL.Add(´Where Container = ´ + quotedstr(edit1.Text)); Dtmodule.QryContainer.Open; if Dtmodule.QryContainer.isEmpty then begin Dtmodule.QryContainer.close; Dtmodule.QryContainer.sql.clear; Dtmodule.QryContainer.sql.add(´INSERT INTO Nvocc_Container (Container,tipo,tamanho,Tara) ´); Dtmodule.QryContainer.sql.add(´ VALUES (´ + quotedstr(Edit1.Text) + ´,´ + quotedstr(Edit2.Text) + ´,´ + quotedstr(Edit3.Text) + ´,´ + quotedstr(Edit9.Text) + ´)´); Dtmodule.QryContainer.execsql; Flag := False; Showmessage(´O Registro ( ´ + Reg + ´ ) Foi Inserido com Sucesso´);
O primeiro codigo funciona beleza.... já este do container nao funciona... achei meio estranho isso...
Gostei + 0
28/09/2005
Fernando_cunha
Gostei + 0
28/09/2005
Rjun
Gostei + 0
28/09/2005
Fernando_cunha
Rjun eu me expliquei mal... na compilacao ele compila.... eu digo se eu rodo o programa dentro do delphi da erro... e fora tbm...
deslcupa , eu entendi malz... é que eu to grilado que nao vai este cadastro.... de 11 que estao funcionando iguais este nao funciona :(
desculpe o nervosismo ...
Gostei + 0
28/09/2005
Rjun
Gostei + 0
28/09/2005
Fernando_cunha
Gostei + 0
28/09/2005
Rjun
Gostei + 0
28/09/2005
Fernando_cunha
Rjun obrigado pela ajuda... funcionou... o problema aqui era que como eu peguei um banco de dados de DBF e converti para MDB não se se tinha algo errado.... eu apaguei a tabela e criei ela de novo e funcionou corretamente...
Desculpe pelo transtorno...
a e eu estou usando o mesmo codigo que eu estava usando mesmo...
obrigado.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)