samedi 31 janvier 2015

Delphi SQlite login procedure crash

been trying to figure out why the following login authentication procedure doesn't work. I have a simple database table holding pupilID and password (in tblPupil) It seems to connect ok upon compilation i.e. that is procedure Connection, but when i run procedure Login...the program seems to crash. In fact, i get no error messages which could illuminate me further! Could this be a database driver problem? (Using Delphi7, SQLite Database with DevartSQLiteDirect driver)



Procedure TForm1.Connection;
begin
SQLConnection1.Params.Add('Database=C:\SQLite\PupilDatabase');
try
// Establish the connection.
SQLConnection1.Connected := true;
label4.Caption := 'OK!';
except
on E: EDatabaseError do
ShowMessage('Exception raised with message' + E.Message);
end;
end;

Procedure TForm1.UserLogin;
var QueryPass : string;
Lcount : String;
cont : boolean;
begin
cont := false;
if InputID.Text = '' then
ShowMessage('Invalid Pupil ID')
else begin
cont := True;
While cont = True do
begin
// A random query
QueryPass := 'SELECT password FROM TblPupil Where pupilID = +InputID.Text+';';
try
// Assign the query to the object SQLQuery1.
SQLQuery1.SQL.Text := QueryPass;
SQLQuery1.open;
except
on E: Exception do
ShowMessage('Exception raised with message: ' + E.Message);
end;
SQLQuery1.First;
Lcount := SQLQuery1.FieldValues['password'];
if Lcount = InputPass.text then
begin
Form1.Hide;
Form16.show;
end
else
begin
ShowMessage('Wrong');
cont := false;
end;
Form1.Hide;
Form16.show;
end;
end;
end;

Aucun commentaire:

Enregistrer un commentaire