Fórum tentando inserir registro na tabela usando SQL porem c\ erro #235128
30/05/2004
0
ele trava minha aplicaçao .. sei la pq .. nao vi nenhum erro pelo menos ...
eu chamo o sql_command(instruçao,tipo) e ele qndo começa a executar da um erro estranho ...
alguem ae sabe me dizer?
ele da um erro assim:
EDBDEEngineError with message ´invalid use of keyword. Token: END,CEP,CIDADE,ESTADO)
procedure TForm1.dxButton1Click(Sender: TObject);
begin
{se o campo de CEP estiver faltando numero}
if (length(suiedit3.Text) < 9) then begin
Dc_MessageDlgCheck(´[AVISO]: O campo de CEP esta incompleto.´, mtError,[mbok],0,mrNo,True);
suiedit3.SetFocus;
exit;
end;
{checa se tem campos vazios}
if (suiedit1.Text = ´´) or (suiedit2.Text = ´´) or (suiedit3.Text = ´´) or (suiedit4.Text = ´´) or (suicombobox1.Text = ´´) then
begin
if (Dc_MessageDlgCheck(´[AVISO]: Você deixou campos em branco, deseja mesmo incluir o registro?´, mtConfirmation,[mbYes, mbNo],0,mrNo,True) = mrYes) then
sql_command(´INSERT INTO banco (RS,END,CEP,CIDADE,ESTADO) VALUES ("´+suiedit1.Text+´","´+suiedit2.Text+´","´+suiedit3.Text+´","´+suiedit4.Text+´","´+suicombobox1.Text+´")´,2);
end else
sql_command(´INSERT INTO banco (RS,END,CEP,CIDADE,ESTADO) VALUES ("´+suiedit1.Text+´","´+suiedit2.Text+´","´+suiedit3.Text+´","´+suiedit4.Text+´","´+suicombobox1.Text+´")´,2);
end;
function TForm1.sql_command(Instrucao: string; Tipo: integer): string;
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(Instrucao);
if (Tipo = 1) then Query1.Open;
if (Tipo = 2) then Query1.ExecSQL;
suiedit1.Clear; suiedit2.Clear; suiedit3.Clear; suiedit4.Clear;
end;Salsa
Curtir tópico
+ 0Posts
30/05/2004
Fer_nanda
Gostei + 0
30/05/2004
Fer_nanda
Ops.. foi mal, SQL Explorer =)
Gostei + 0
31/05/2004
Dankada
procedure TForm1.dxButton1Click(Sender: TObject);
begin
{se o campo de CEP estiver faltando numero}
if (length(suiedit3.Text) < 9) then begin
Dc_MessageDlgCheck(´[AVISO]: O campo de CEP esta incompleto.´, mtError,[mbok],0,mrNo,True);
suiedit3.SetFocus;
exit;
end;
{checa se tem campos vazios}
if (suiedit1.Text = ´´) or (suiedit2.Text = ´´) or (suiedit3.Text = ´´) or (suiedit4.Text = ´´) or (suicombobox1.Text = ´´) then
begin
if (Dc_MessageDlgCheck(´[AVISO]: Você deixou campos em branco, deseja mesmo incluir o registro?´, mtConfirmation,[mbYes, mbNo],0,mrNo,True) = mrYes) then
sql_command(´INSERT INTO banco (RS,END,CEP,CIDADE,ESTADO) VALUES ("´+suiedit1.Text+´","´+suiedit2.Text+´","´+suiedit3.Text+´","´+suiedit4.Text+´","´+suicombobox1.Text+´")´,2); //aki
end else
sql_command(´INSERT INTO banco (RS,END,CEP,CIDADE,ESTADO) VALUES ("´+suiedit1.Text+´","´+suiedit2.Text+´","´+suiedit3.Text+´","´+suiedit4.Text+´","´+suicombobox1.Text+´")´,2); //aki
end;
function TForm1.sql_command(Instrucao: string; Tipo: integer): string;
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(Instrucao);
if (Tipo = 1) then Query1.Open;
if (Tipo = 2) then Query1.ExecSQL;
suiedit1.Clear; suiedit2.Clear; suiedit3.Clear; suiedit4.Clear;
end;ola salsa,
veja, vc ta passando o parametro em ambos os casos com o Numero 2 onde esta comentado do lado do codigo.
E outra coisa vc pergunta se deseja incluir mesmo com registros em branco sendo que se eu clica em Não ou clicar em SIM ele vai executar a mesma rotina.
outra coisa vc poderia mudar a rotina sql_command para uma procedure ja que ela naum tem retorno.
e sobre o erro que esta dando, EDBDEEngineError eh uma exceção e ele ta dando a msg de ´uso invalido da palavra chave´ verifique se os campos da tabela estao corretos.
[ ]´s
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)