Prezados Colegas , Estou fazendo uma classe simples de cliente, 1 - mas no meu construtor, quando chega no atributo Cidade - aparece access violation. ? 2 - E nessa mesma classe estou criando um IBSQL para fazer um insert , mas da erro IBErro... no FiledByName. Preciso criar os paramentro antes ? como faria isso ?
Qualquer dica é bem vinda Segue código abaixo : unit Cliente; interface uses Dialogs, IBSQL; type TCliente = class private //Atributos FCod: integer; FNome: string; FNomeReduzido: string; FEndereco : string; FNumero : string; FComplemento : string; FBairro : string; FCidade : string; function BuscaNoBanco(const pegaCod: integer): boolean; protected //Métodos para as propriedades function GetNome : string; procedure SetNome (Value : string); public //Propriedades Publicas property Cod: integer read FCod write FCod; property Nome: string read GetNome write SetNome; property NomeReduzido: string read FNomeReduzido write FNomeReduzido; property Endereco : string read FEndereco write FEndereco ; property Numero : string read FNumero write FNumero ; property Complemento : string read FComplemento write FComplemento ; property Bairro : string read FBairro write FBairro ; property Cidade : string read FCidade write FCidade ; //Métodos Publicos function Incluir: boolean; //Construtores Públicos constructor Cria;overload; constructor Cria(const paramCod: integer);overload; end; implementation uses AmbData; { TCliente } constructor TCliente.Cria; begin inherited Create; FCod:=0; FNome:=''; FNomeReduzido:=''; FEndereco:=''; FNumero:=''; FComplemento:=''; FBairro:=''; FCidade:=''; end; constructor TCliente.Cria(const paramCod: integer); begin inherited Create; if not BuscaNoBanco(paramCod) then ShowMessage(Mensagem); end; function TCliente.BuscaNoBanco(const pegaCod: integer): boolean; var Qry: TIBSQL; begin Qry := TIBSQL.Create(nil); try Qry.Database := dtmAmb.dbFB; Qry.Close; Qry.SQL.Text := 'SELECT * FROM CLIENTE WHERE Cliente = :Cliente'; Qry.ParamByName('Cliente').Value := pegaCod; Qry.ExecQuery; if not Qry.Eof then begin Cod := pegaCod; Nome := Qry.Fields[1].Value; NomeReduzido:= Qry.Fields[2].Value; Result := True; end else Result := False; Qry.FreeHandle; finally Qry.Free; end; // try end; function TCliente.Incluir: boolean; var Qry: TIBSQL; begin //Rotina Principal Qry := TIBSQL.Create(nil); try try Qry.Database := dtmAmb.dbFB; Qry.Close; Qry.SQL.Text:='INSERT INTO FIN_CLIENTE (CLIENTE, NOME, '+ 'NOMEREDUZIDO, ENDERECO, NUMERO, COMPLEMENTO,'+ 'BAIRRO, CIDADE) '+ 'VALUES (:CLIENTE, :NOME, :NOMEREDUZIDO, :ENDERECO, :NUMERO, :COMPLEMENTO,'+ ':BAIRRO, :CIDADE'; Qry.ParamByName('CLIENTE').Value := Cod; Qry.ParamByName('NOME').Value := Nome; Qry.ParamByName('NOMEREDUZIDO').Value := XStrRightAdd(' ', XStrAnsiToAlpha(NomeReduzido), 15); Qry.ParamByName('ENDERECO').Value := XStrRightAdd(' ', XStrAnsiToAlpha(Endereco), 15 ); Qry.ParamByName('NUMERO').Value := XStrRightAdd(' ', XStrAnsiToAlpha(NUMERO), 7 ); Qry.ParamByName('COMPLEMENTO').Value := XStrRightAdd(' ', XStrAnsiToAlpha(COMPLEMENTO), 15); Qry.ParamByName('BAIRRO').Value := XStrRightAdd(' ', XStrAnsiToAlpha(BAIRRO), 20); Qry.ParamByName('CIDADE').Value := XStrRightAdd(' ', XStrAnsiToAlpha(CIDADE), 40); Qry.ExecQuery; Result := True; except Result := False; end; Qry.FreeHandle; finally Qry.Free; end; // try end; function TCliente.GetNome: string; begin Result := Self.FNome; end; procedure TCliente.SetNome(Value: string); begin Self.FNome := Value; end; end. Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento! http://br.mail.yahoo.com/ [As partes desta mensagem que não continham texto foram removidas]