Hola ecfisa nuevamente al ingresar los 2 códigos en DATAMODULE02 y el Formulario de Login todo conecta correctamente pero cuando intento seleccionar el usuario del DBLOOKUPCOMBOBOX y pongo el password y clic en aceptar me bota el siguiente error:
Cita:
(Project Sistema.exe raised exception class EIBInterBaseError with message 'Dynamic SQL Error SQL error code= -204
Table unknown
USUARIO'.Process stopped. Use Step or Run to continue.)
|
Así ingrese los 2 formularios editando algunos nombres:
DATAMODULE02
Código Delphi
[-]
unit DataModule02;
interface
uses
SysUtils, Classes, DB, IBCustomDataSet, IBDatabase, IBQuery, IBTable,
IBStoredProc;
type
TDataModule2 = class(TDataModule)
IBTransaction1: TIBTransaction;
Procedimientos: TIBStoredProc;
IBTEmpresas: TIBTable;
IBQEmpresas1: TIBQuery;
DSEmpresas: TDataSource;
DSEmpresas1: TDataSource;
IBTAgencia: TIBTable;
IBQAgencia1: TIBQuery;
DSAgencia: TDataSource;
DSAgencia1: TDataSource;
IBTUsuarios: TIBTable;
DSUsuarios: TDataSource;
IBQUsuarios1: TIBQuery;
DSUsuarios1: TDataSource;
IBDatabase1: TIBDatabase;
IBTDNI: TIBTable;
IBTDNIDES_DOC_IDE: TIBStringField;
IBTDNICOD_DOC_IDE: TIBStringField;
DSDNI: TDataSource;
IBQDNI: TIBQuery;
DTDNI1: TDataSource;
IBTTipodePersona: TIBTable;
IBQTipodePersona: TIBQuery;
DSTipodePersona: TDataSource;
DSTipodePersona1: TDataSource;
IBTEstadoCivil: TIBTable;
IBQEstadoCivil: TIBQuery;
DSEstadoCivil: TDataSource;
DSEstadoCivil1: TDataSource;
IBTZona: TIBTable;
IBQZona: TIBQuery;
DSZona: TDataSource;
DSZona1: TDataSource;
IBTPassword: TIBTable;
DSPassword: TDataSource;
IBQPassword: TIBQuery;
DSPassword1: TDataSource;
private
public
function LoginAccepted(qy: TIBQuery; const nam, pwd: string): Boolean;
end;
var
DataModule2: TDataModule2;
implementation {$R *.dfm}
function TDataModule2.LoginAccepted(qy: TIBQuery; const nam, pwd: string): Boolean;
begin
qy.Close;
qy.SQL.Clear;
qy.SQL.Add('SELECT * FROM USUARIO');
qy.SQL.Add('WHERE NOMBRE = :NOMBRE');
qy.ParamByName('NOMBRE').AsString := nam;
qy.Open;
Result := not qy.IsEmpty and (qy.FieldByName('CLAVE').AsString = pwd);
qy.Close;
end;
end.
Formulario del Login:
Código Delphi
[-]
unit AccesoAlSistema;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, Buttons, ExtCtrls;
type
TAccesoSistema = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Empresa: TLabel;
Agencia: TLabel;
Usuarios: TLabel;
Password: TLabel;
Aceptar: TBitBtn;
Cancelar: TBitBtn;
edtEmpresa: TDBLookupComboBox;
edtAgencia: TDBLookupComboBox;
edtUsuarios: TDBLookupComboBox;
edtPassword: TEdit;
procedure CancelarClick(Sender: TObject);
procedure AceptarClick(Sender: TObject);
private
public
end;
var
AccesoSistema: TAccesoSistema;
implementation {$R *.dfm}
uses DataModule02;
procedure TAccesoSistema.CancelarClick(Sender: TObject);
begin
close;
end;
procedure TAccesoSistema.AceptarClick(Sender: TObject);
begin
if not DataModule2.LoginAccepted(DataModule2.IBQPassword, edtUsuarios.Text, edtPassword.Text) then
raise Exception.Create('El usuario o la contraseña son inválidos.');
end;
end.