project Empreendimetos.exe raised exception class econvert e

Delphi

30/07/2008

Estou com um problema no programa que estou desenvolvendo , na pagina de consulta esta dando o seguinte erro: [b:cbd6cf89ee]project Empreendimetos.exe raised exception class econvert error with message ´ VILA NOVASUZANO is not a valid integer value´[/b:cbd6cf89ee]
meu codigo:

unit uConsEmpreendimentos;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, Mask, DBCtrls, ExtCtrls, DB,
IBCustomDataSet, Buttons, IBUpdateSQL, IBQuery;

type
TfrmConsEmpreendimentos = class(TForm)
dsConsEmpree: TDataSource;
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
GridConsEmpree: TDBGrid;
Panel3: TPanel;
btnSair: TBitBtn;
btnConsultar: TBitBtn;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
ibqEmpreendimento: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
edtNome: TEdit;
edtEnd: TEdit;
edtBairro: TEdit;
edtRegiao: TEdit;
edtDormitorios: TEdit;
edtMetragem: TEdit;
edtMetragemFinal: TEdit;
edtValor_inicial: TEdit;
edtValor_final: TEdit;
ibqEmpreendimentoID_EMPREE: TIntegerField;
ibqEmpreendimentoNOME: TIBStringField;
ibqEmpreendimentoENDERECO: TIBStringField;
ibqEmpreendimentoBAIRRO: TIBStringField;
ibqEmpreendimentoREGIAO: TIBStringField;
ibqEmpreendimentoESTADO: TIBStringField;
ibqEmpreendimentoLANCAMENTO: TIBStringField;
ibqEmpreendimentoVALOR: TFloatField;
ibqEmpreendimentoMETRAGEM: TIBBCDField;
ibqEmpreendimentoQTDE_DORM: TIBBCDField;
ibqEmpreendimentoQTDE_DORM_B: TIBBCDField;
ibqEmpreendimentoCARACTERISTICAS: TIBStringField;
procedure btnConsultarClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormActivate(Sender: TObject);
procedure btnSairClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
frmConsEmpreendimentos: TfrmConsEmpreendimentos;

implementation

uses DM, uPrincipal;

{$R *.dfm}

procedure TfrmConsEmpreendimentos.btnConsultarClick(Sender: TObject);

var i : integer;
begin

if (Trim(edtNome.Text)= ´´)and
(Trim(edtEnd.Text)=´´)and
(Trim(edtBairro.Text)= ´´)and
(Trim(edtRegiao.Text)= ´´) and
(Trim(edtDormitorios.Text)= ´´)and
(Trim(edtMetragem.Text)= ´´)and
(Trim(edtMetragemFinal.Text)= ´´)and
(Trim(edtValor_inicial.Text)= ´´)and
(Trim(edtValor_Final.Text)= ´´)then

begin
ShowMessage(´É necessário informar pelo menos um ´+#13+ ´dos campos para fazer a pesquisa!´);
Exit;

end;

with ibqEmpreendimento do

begin
Close;
SQL.Clear;
SQL.Add(´select * from EMPREENDIMENTOS´);

if Trim(edtNome.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then

SQL.Add(´and ID_EMPREE =: ID_EMPREE´)

else

SQL.Add(´Where ID_EMPREE =:ID_EMPREE´);
ParamByName(´ID´).Value:= StrToInt(edtNome.Text);
end;

if Trim(edtNome.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and NOME like:NOME´)

else
SQL.Add(´Where NOME like:NOME´);
ParamByName(´NOME´).Value:= edtNome.Text + ´¬´;
end;

if Trim(edtEnd.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and ENDERECO like:ENDERECO´)

else
SQL.Add(´Where ENDERECO like:ENDERECO´);
ParamByName(´ENDERECO´).Value:= edtEnd.Text + ´¬´;
end;

if Trim(edtBairro.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and BAIRRO like:BAIRRO´)

else
SQL.Add(´Where BAIRRO like:BAIRRO´);
ParamByName(´BAIRRO´).Value:= edtBairro.Text + ´¬´;
end;

if Trim(edtDormitorios.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and DORMITORIO like:DORMITORIO´)

else
SQL.Add(´Where DORMITORIO like:DORMITORIO´);
ParamByName(´DORMITORIO´).Value:= edtDormitorios.Text + ´¬´;

if Trim(edtMetragem.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and METRAGEM like:METRAGEM´)

else
SQL.Add(´Where METRAGEM like:METRAGEM´);
ParamByName(´METRAGEM´).Value:= edtMetragem.Text + ´¬´;

end;

if Trim(edtMetragemFinal.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and METRAGEM like:METRAGEM´)

else
SQL.Add(´Where METRAGEM like:METRAGEM´);
ParamByName(´METRAGEM´).Value:= edtMetragemFinal.Text + ´¬´;

end;

if Trim(edtValor_inicial.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and VALOR like:VALOR´)

else
SQL.Add(´Where VALOR like:VALOR´);
ParamByName(´VALOR´).Value:= edtValor_inicial.Text + ´¬´;

end;

if Trim(edtValor_final.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and VALOR like:VALOR´)

else
SQL.Add(´Where VALOR like:VALOR´);
ParamByName(´VALOR´).Value:= edtValor_final.Text + ´¬´;

end;

end;



try
ibqEmpreendimento.Open;
Except
On E: Exception do
ShowMessage(E.Message);
end;
for i:= 0 to Panel1.ComponentCount-1 do
begin
if (Panel1.Components[i] is TEdit) then
TEdit(Panel1.Components[i]).Clear;
end;


edtNome.Clear;
edtEnd.Clear;
edtBairro.Clear;
edtDormitorios.Clear;
edtMetragem.Clear;
edtMetragemFinal.Clear;
edtValor_Final.Clear;
edtValor_Inicial.Clear;
end;




if (Trim(edtNome.Text)= ´´)and
(Trim(edtEnd.Text)=´´)and
(Trim(edtBairro.Text)= ´´)and
(Trim(edtDormitorios.Text)= ´´)and
(Trim(edtMetragem.Text)= ´´)and
(Trim(edtMetragemFinal.Text)= ´´)and
(Trim(edtValor_Inicial.Text)= ´´)and

(Trim(edtValor_Final.Text)= ´´) then

begin
ShowMessage(´É necessário informar pelo menos um ´+#13+ ´dos campos para fazer a pesquisa!´);
Exit;

end;

with ibqEmpreendimento do

begin
Close;
SQL.Clear;
SQL.Add(´select * from EMPREENDIMENTOS´);

if Trim(edtNome.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then

SQL.Add(´and NOME =:NOME´)

else

SQL.Add(´Where NOME =:NOME´);
ParamByName(´NOME´).Value:= StrToInt(edtNome.Text);
end;

if Trim(edtEnd.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and ENDERECO like:ENDERECO´)

else
SQL.Add(´Where ENDERECO like:ENDERECO´);
ParamByName(´EMDERECO´).Value:= edtEnd.Text + ´¬´;
end;

if Trim(edtBairro.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and BAIRRO like:BAIRRO´)

else
SQL.Add(´Where BAIRRO like:BAIRRO´);
ParamByName(´BAIRRO´).Value:= edtBairro.Text + ´¬´;
end;

if Trim(edtDormitorios.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and DORMITORIOS like:DORMITORIOS´)

else
SQL.Add(´Where DORMITORIOS like:DORMITORIOS´);
ParamByName(´DORMITORIOS´).Value:= edtDormitorios.Text + ´¬´;
end;

if Trim(edtMetragem.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and METRAGEM like:METRAGEM´)

else
SQL.Add(´Where METRAGEM like:METRAGEM´);
ParamByName(´METRAGEM´).Value:= edtMetragem.Text + ´¬´;
end;

if Trim(edtMetragemFinal.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and METRAGEMFINAL like:METRAGEMFINAL´)

else
SQL.Add(´Where METRAGEMFINAL like:METRAGEMFINAL´);
ParamByName(´METRAGEMFINAL´).Value:= edtMetragemFinal.Text + ´¬´;
end;

if Trim(edtValor_Inicial.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and VALOR like:VALOR´)

else
SQL.Add(´Where VALOR like:VALOR´);
ParamByName(´VALOR´).Value:= edtValor_Inicial.Text + ´¬´;
end;

if Trim(edtValor_Final.Text)<>´´ then

begin
if Pos(´h´,SQL.Text)<>0 then
SQL.Add(´and VALOR like:VALOR´)

else
SQL.Add(´Where VALORFINAL like:VALORFINAL´);
ParamByName(´VALORFINAL´).Value:= edtValor_Final.Text + ´¬´;
end;
end;

try
ibqEmpreendimento.Open;
Except
On E: Exception do
ShowMessage(E.Message);
end;

// for i:= 0 to Panel1.ComponentCount-1 do
begin
// if (Panel1.Components[i] is TEdit) then
// TEdit(Panel1.Components[i]).Clear;

edtNome.Clear;
edtEnd.Clear;
edtBairro.Clear;
edtDormitorios.Clear;
edtMetragem.Clear;
edtMetragemFinal.Clear;
edtValor_Final.Clear;
edtValor_Inicial.Clear;
end;



end;




procedure TfrmConsEmpreendimentos.btnSairClick(Sender: TObject);
begin
Close;
end;

procedure TfrmConsEmpreendimentos.FormActivate(Sender: TObject);
begin
edtNome.SetFocus;
end;

procedure TfrmConsEmpreendimentos.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
end;

end.


Mary

Mary

Curtidas 0

Respostas

Aroldo Zanela

Aroldo Zanela

30/07/2008

Colega,

Alguns parâmetros estão nomeados incorretamente. Não sei se consegui visualizar todos, mas encontrei três erros.
Dê uma revisada em seu código e sempre utilize espaço após o sinal de igualdade e nunca entre os dois pontos (:) e o nome de parâmetro.

Certo

nome_parametro = :nome

Errado

nome_parametro =: nome

if Trim(edtNome.Text)<>´´ then
begin
  if Pos(´h´,SQL.Text)<>0 then
    SQL.Add(´and ID_EMPREE = :ID_EMPREE´)
  else
    SQL.Add(´Where ID_EMPREE = :ID_EMPREE´);

  ParamByName(´ID´).Value:= StrToInt(edtNome.Text);
               -- // Nome do parâmetro deve ser o mesmo acima  ID_EMPREE E NÃO ID
end; 


if Trim(edtEnd.Text)<>´´ then 
begin
  if Pos(´h´,SQL.Text)<>0 then
    SQL.Add(´and ENDERECO like :ENDERECO´)
  else
    SQL.Add(´Where ENDERECO like :ENDERECO´);
  ParamByName(´EMDERECO´).Value:= edtEnd.Text + ´¬´;
               --------   // ENDERECO E NAO EMDERECO
end;


if Trim(edtValor_Final.Text)<>´´ then
begin
  if Pos(´h´,SQL.Text)<>0 then
    SQL.Add(´and VALOR like :VALOR´)
                 -----       ----- // VALORFINAL E NÃO VALOR
  else
    SQL.Add(´Where VALORFINAL like:VALORFINAL´);
  ParamByName(´VALORFINAL´).Value:= edtValor_Final.Text + ´¬´;
end;



GOSTEI 0
POSTAR