Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ULogin unit;
- interface
- uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, dialogs, StdCtrls, DB, ADODB;
- type
- TFrmLogin = class (TForm)
- Label1: TLabel;
- edusername: TEdit;
- Label2: TLabel;
- edpassword: TEdit;
- Button1: TButton;
- ADOQuery1: TADOQuery;
- ADOConnection1: TADOConnection;
- Button1Click procedure (Sender: TObject);
- FormCreate procedure (Sender: TObject);
- private
- {Private Declarations}
- public
- {Public Declarations} end;
- var FrmLogin: TFrmLogin;
- implementation uses
- / / XPMan for display form such as the button following the theme on windows
- / / Add to ULogin UHasilLogin unit by pressing Alt + F11, or with
- / / typed it
- XPMan, UHasilLogin;
- {$ R *. DFM}
- TFrmLogin.FormCreate procedure (Sender: TObject);
- var
- s: Char;
- alamatdb: WideString;
- begin
- / / Manipulation cursors crSQLWait order not to appear
- Screen.Cursors [crSQLWait]: = Screen.Cursors [crDefault];
- / / set the display form
- s: = '*';
- edusername.Text: ='';
- edpassword.PasswordChar: = s;
- edpassword.Text: ='';
- / / set the connection on ADOConnection
- / / This script allows you to manage database connections in applications
- / / in order to application can process database that has been selected in a computer
- / / anywhere without the need to have a path / address the same database.
- alamatdb: = ExtractFilePath (Application.ExeName) + 'data.mdb';
- with ADOConnection1 do begin
- Connected: = False;
- LoginPrompt: = False;
- Mode: = cmShareDenyNone;
- ConnectionString: = 'Provider = Microsoft.Jet.OLEDB.4.0; Data Source =' +
- alamatdb + '; persist Security Info = False';
- end;
- ADOConnection1.Connected: = True;
- end;
- TFrmLogin.Button1Click procedure (Sender: TObject);
- begin
- with ADOQuery1 do begin
- Close;
- SQL.Clear; / / clear command sql if there is.
- SQL.Add ('SELECT * FROM login WHERE username =' +
- QuotedStr (edusername.Text));
- Open;
- end; / / end with
- / / if not found then the data sought
- / / display message
- if ADOQuery1.RecordCount = 0 then
- Application.MessageBox ('Sorry, your username does not exist', 'Information',
- MB_OK or MB_ICONINFORMATION)
- else begin
- if ADOQuery1.FieldByName ('password'). AsString <> edpassword.Text then
- Application.MessageBox ('Make sure the correct username or password',
- 'Error', MB_OK or MB_ICONERROR)
- else begin
- Hide;
- Form1.Show;
- end
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement