Onde esta o erro nessa SQL

Delphi

12/05/2004

procedure TfrmEmpresa.tfXPButton1Click(Sender: TObject);
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(´insert into EMPRESA (nome_empresa,cidade,superintendente,) values (:nome_empresa,:cidade,:superintendente,)´);
ADOQuery1.Parameters.ParamByName(´nome_empresa´).Value:=edit1.Text;
ADOQuery1.Parameters.ParamByName(´cidade´).Value:=edit2.Text;
ADOQuery1.Parameters.ParamByName(´superintendente´).Value:=edit3.Text;
if not ADOQuery1.Prepared then
ADOQuery1.Prepared:=true;
Try
ADOQuery1.Open;
showmessage(´Empresa cadastrada com sucesso!´)
except
showmessage(´Não foi possível cadastrar!´)
end; 


Agradeco qualquer ajuda


Redoctober

Redoctober

Curtidas 0

Respostas

Vinicius2k

Vinicius2k

12/05/2004

Colega,
ADOQuery1.[color=red:9f0aa01243]Open[/color:9f0aa01243];

O método Open só é utilizado em queryes com a instrução SELECT (existe retorno de cursor para os dados)... para as instruções INSERT, UPDATE e DELETE, ou DDL (CREATE TABLE, ALTER TABLE, etc.), utilize o método ExecSQL :
ADOQuery1.ExecSQL;


Espero ter ajudado...

T+


GOSTEI 0
Fer_nanda

Fer_nanda

12/05/2004

(nome_empresa,cidade,superintendente[color=red:2bf0a0a48b],[/color:2bf0a0a48b]) values (:nome_empresa,:cidade,:superintendente[color=red:2bf0a0a48b],[/color:2bf0a0a48b])´);


Além do q o Vinicius falou, retire essas vírgulas no final de superintendente.


GOSTEI 0
Vinicius2k

Vinicius2k

12/05/2004

[quote:121fd55f0c=´redoctober´](nome_empresa,cidade,superintendente[color=red:121fd55f0c],[/color:121fd55f0c]) values (:nome_empresa,:cidade,:superintendente[color=red:121fd55f0c],[/color:121fd55f0c])´);

Além do q o Vinicius falou, retire essas vírgulas no final de superintendente.[/quote:121fd55f0c]

Boa ! eu não tinha visto isso...


GOSTEI 0
Redoctober

Redoctober

12/05/2004

[quote:fbb423a4d2=´fer_nanda´][quote:fbb423a4d2=´redoctober´](nome_empresa,cidade,superintendente[color=red:fbb423a4d2],[/color:fbb423a4d2]) values (:nome_empresa,:cidade,:superintendente[color=red:fbb423a4d2],[/color:fbb423a4d2])´);

Além do q o Vinicius falou, retire essas vírgulas no final de superintendente.[/quote:fbb423a4d2]

Boa ! eu não tinha visto isso...[/quote:fbb423a4d2]

Vocês estão me ajudando muito!!!

Abracos e obrigado


GOSTEI 0
POSTAR