Lista primeiramente obrigado pela ajuda de como colocar o access em 
rede.. agora outra coisa... nao sei mais o que fazer.. tenho as 2 classes 
abaixo... a Classe setor Funciona certinho.. mas a classe Local da erro ao 
executar qualquer coisa no banco... o erro é exception class EoleException 
'Erro não especificado'..... não sei mais o que fazer... as 2 classes não 
igualzinhas.... só muda o nome.... e as duas estão usando a mesma conexão.... 
Alguma idéia.. ??


Wesley


unit UClasses;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, Menus, StdCtrls;

{ Classe Setor  }
type
      TSetor = class
          function  GeraCodigoNovo : Integer ;
          procedure AcoesBanco ( ACAO  : Integer  ; CDSTR , DESCR : String ) ;
          procedure Consulta   ( VALUE : Variant  );
      public
          Banco : TADOQuery ;
end;



{ Classe Local  }
type
    TLocal = class
        function  GeraCodigoNovo : Integer  ;
        procedure AcoesBanco ( ACAO : Integer ; CDLCL , DESCR : string ) ;
        procedure Consulta ( VALUE : Variant );
    public
        Banco : TADOQuery ;
end;

implementation


{ Acoes Banco }
procedure TSetor.AcoesBanco(ACAO: Integer; CDSTR, DESCR: String);
begin
    with Banco do
        begin
              case Acao of
                  { Incluir }
                  1 : begin
                            Close;
                            Sql.Clear;
                            Sql.Text  := 'INSERT INTO SETOR VALUES ( :CDSTR  , 
:DESCR )';
                            Parameters.ParamByName('CDSTR').Value := StrToInt( 
CDSTR )  ;
                            Parameters.ParamByName('DESCR').Value := Trim( 
DESCR );
                            ExecSQL;
                            Close;
                        end;

                  { Alterar }
                  2 : begin
                            Close;
                            Sql.Clear;
                            Sql.Text  := 'UPDATE SETOR SET DESCR=:DESCR WHERE 
CDSTR=:CDSTR';
                            Parameters.ParamByName('CDSTR').Value := StrToInt( 
CDSTR )  ;
                            Parameters.ParamByName('DESCR').Value := Trim( 
DESCR );
                            ExecSQL;
                            Close;
                        end;

                  { Deletar }
                  3 : begin
                            Close;
                            Sql.Clear;
                            Sql.Text  := 'DELETE FROM SETOR WHERE CDSTR=:CDSTR';
                            Parameters.ParamByName('CDSTR').Value := StrToInt( 
CDSTR )  ;
                            ExecSQL;
                            Close;
                        end;
              end
          end
end;


{ Gera codigo Novo  }
function TSetor.GeraCodigoNovo: Integer;
begin
    with Banco do
        begin
              Close;
              Sql.Clear;
              Sql.Text  := 'SELECT MAX ( CDSTR ) FROM SETOR';
              Open;
              if IsEmpty then
                  Result  := 1
              else
                  Result  := Fields[0].AsInteger + 1 ;
              Close;
          end
end;


{ Consulta  }
procedure TSetor.Consulta(VALUE: Variant);
begin
    with banco do
        begin
              Close;
              Sql.Clear;
              Sql.Text  := 'SELECT * FROM SETOR WHERE DESCR LIKE ''' + value + 
'%'' ORDER BY DESCR' ;
              Open;
          end
end;










{ Acoes Banco }
procedure TLocal.AcoesBanco(ACAO: Integer; CDLCL, DESCR: string);
begin
    with Banco do
        begin
              case Acao of
                  //Incluir
                  1 : begin
                            Close;
                            Sql.Clear;
                            Sql.Text  := 'INSERT INTO LOCAL VALUES ( :CDLCL , 
:DESCR )';
                            Parameters.ParamByName('CDLCL').Value := StrToInt( 
CDLCL );
                            Parameters.ParamByName('DESCR').Value := Trim( 
DESCR );
                            ExecSQL;
                            Close;
                        end;

                  //Alterar
                  2 : begin
                            Close;
                            Sql.Clear;
                            Sql.Text  := 'UPDATE LOCAL SET DECSR=:DESCR WHERE 
CDLCL=:CDLCL';
                            Parameters.ParamByName('CDLCL').Value := StrToInt( 
CDLCL );
                            Parameters.ParamByName('DESCR').Value := Trim( 
DESCR );
                            ExecSQL;
                            Close;
                        end;

                  //EXcluir
                  3 : begin
                            Close;
                            Sql.Clear;
                            Sql.Text  := 'DELETE FROM LOCAL WHERE CDLCL=:CDLCL';
                            Parameters.ParamByName('CDLCL').Value := StrToInt( 
CDLCL );
                            ExecSQL;
                            Close;
                        end
              end;
          end
end;


{ Consulta  }
procedure TLocal.Consulta(VALUE: Variant);
begin
    with Banco do
        begin
              Close;
              Sql.Clear;
              Sql.Text  := 'SELECT * FROM LOCAL WHERE DESCR LIKE ''' + Value + 
'%'' ORDER BY DESCR';
              Open;
          end
end;


{ gera Codigo }
function TLocal.GeraCodigoNovo: Integer;
begin
    with Banco do
        begin
              Close;
              Sql.Clear;
              Sql.Text  := 'SELECT MAX ( CDLCL ) FROM LOCAL';
              Open;
              ShowMessage( 'Abriu' );
              if IsEmpty then
                  Result  := 1
              else
                  Result  := Fields[0].AsInteger + 1 ;
              Close;
          end
end;



end.

[As partes desta mensagem que não continham texto foram removidas]

Responder a