這是我的代碼
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, ADODB,Unit2;
type
Talogo = class(TForm)
Label1: TLabel;
Label2: TLabel;
edtName: TEdit;
edtPwd: TEdit;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
alogo: Talogo;
admin: TAdminMain;
name,userpwd:String;
implementation
{$R *.dfm}
procedure Talogo.BitBtn1Click(Sender: TObject);
begin
try
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select * from admin where LoginId=:name and LoginPwd=:userpwd');
parameters.ParamByName('name').Value:=trim(edtName.Text);
parameters.ParamByName('userpwd').Value:=trim(edtPwd.Text);
if edtName.Text='' then
begin
application.MessageBox('請輸入賬號','提示資訊',64);
edtName.SetFocus;
end;
if edtpwd.Text='' then
begin
application.MessageBox('請輸入密碼','提示資訊',64);
edtpwd.SetFocus;
exit;
end;
open;
end;
if adoquery1.RecordCount<>0 then
begin
name:=edtName.Text;
userpwd:=edtPwd.Text;
application.MessageBox('登陸成功','提示資訊',64);
admin.Show;
self.Hide;
end
else
application.MessageBox('輸入的賬號或密碼錯誤','提示資訊',64);
except
application.MessageBox('登錄失敗請重新登錄','提示資訊',64);
end;
end;
end.
這幾張是我操作時的截的圖
里面的賬號密碼在資料庫中是有的,但我百度了很久還是沒找到原因。






uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
procedure Talogo.BitBtn1Click(Sender: TObject);
begin
if edtName.Text='' then
begin
application.MessageBox('請輸入賬號','提示資訊',64);
edtName.SetFocus;
Exit;
end;
if edtpwd.Text='' then
begin
application.MessageBox('請輸入密碼','提示資訊',64);
edtPwd.SetFocus;
Exit;
end;
try
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select * from admin where LoginId=:name and LoginPwd=:userpwd');
parameters.ParamByName('name').Value:=trim(edtName.Text);
parameters.ParamByName('userpwd').Value:=trim(edtPwd.Text);
open;
end;
if adoquery1.RecordCount<>0 then
begin
name:=edtName.Text;
userpwd:=edtPwd.Text;
// application.MessageBox('登陸成功','提示資訊',64); // 登錄成功不要顯示 直接進入下一視窗
admin.Show;
self.Hide;
end
else application.MessageBox('輸入的賬號或密碼錯誤','提示資訊',64);
except
application.MessageBox('登錄失敗請重新登錄','提示資訊',64);
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/88783.html
標籤:語言基礎/算法/系統設計
上一篇:ImageEn5.2的TImageEnMView,無法只用橫向滾動條(不顯示)
下一篇:在線等,求c#加密字串(包括漢字)演算法,用delphi解密的函式演算法,需要 c#加密函式和delphi解密函式,高分。
