先设ODBC,再按如下使用:
function TTCSBADataModule.Connect: Boolean;
begin
{ Connects the user to the database. When dbSales is set to True, its OnLogon
event handler will be invoked which will invoke our customer login dialog
defined in LoginFrm.pas. }
try
dbTCSBA.Connected := True; //触发ONLOGIN事件
Result := True; except
if blLoginFlag then
//MessageDlg('Invalid Password or login information, cannot login.', mtError, [mbok], 0);
MessageDlg('错误的口令或者登录信息,无法登录.', mtError, [mbok], 0);
dbTCSBA.Connected := False;
Result := False;
end;
end;
procedure TTCSBADataModule.dbTCSBALogin(Database: TDatabase;
LoginParams: TStrings);
begin
blLoginFlag:=GetLoginParams(LoginParams);
end;//login windowsunit LoginFrm;interfaceuses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls;type
TLoginForm = class(TForm)
lblEnterPassword: TLabel;
lblEnterName: TLabel;
edtName: TEdit;
edtPassword: TEdit;
btnOK: TButton;
btnCancel: TButton;
public
end;function GetLoginParams(ALoginParams: TStrings): Boolean;implementation{$R *.DFM}function GetLoginParams(ALoginParams: TStrings): Boolean;
var
LoginForm: TLoginForm;
begin
Result := False;
LoginForm := TLoginForm.Create(Application);
try
if LoginForm.ShowModal = mrOk then
begin
ALoginParams.Values['USER NAME'] := LoginForm.edtName.Text;
ALoginParams.Values['PASSWORD'] := LoginForm.edtPassWord.Text;
Result := True;
end;
finally
LoginForm.Free;
end;
end;end.
function TTCSBADataModule.Connect: Boolean;
begin
{ Connects the user to the database. When dbSales is set to True, its OnLogon
event handler will be invoked which will invoke our customer login dialog
defined in LoginFrm.pas. }
try
dbTCSBA.Connected := True; //触发ONLOGIN事件
Result := True; except
if blLoginFlag then
//MessageDlg('Invalid Password or login information, cannot login.', mtError, [mbok], 0);
MessageDlg('错误的口令或者登录信息,无法登录.', mtError, [mbok], 0);
dbTCSBA.Connected := False;
Result := False;
end;
end;
procedure TTCSBADataModule.dbTCSBALogin(Database: TDatabase;
LoginParams: TStrings);
begin
blLoginFlag:=GetLoginParams(LoginParams);
end;//login windowsunit LoginFrm;interfaceuses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls;type
TLoginForm = class(TForm)
lblEnterPassword: TLabel;
lblEnterName: TLabel;
edtName: TEdit;
edtPassword: TEdit;
btnOK: TButton;
btnCancel: TButton;
public
end;function GetLoginParams(ALoginParams: TStrings): Boolean;implementation{$R *.DFM}function GetLoginParams(ALoginParams: TStrings): Boolean;
var
LoginForm: TLoginForm;
begin
Result := False;
LoginForm := TLoginForm.Create(Application);
try
if LoginForm.ShowModal = mrOk then
begin
ALoginParams.Values['USER NAME'] := LoginForm.edtName.Text;
ALoginParams.Values['PASSWORD'] := LoginForm.edtPassWord.Text;
Result := True;
end;
finally
LoginForm.Free;
end;
end;end.
解决方案 »
- XE2下的"Cannot assign a TFont to a TFont"
- 当鼠标移到菜单上时,怎样在状态栏显示说明文字
- 请高手指教一个动态库问题
- Socket通信时是否有最大连接数的限制?
- delphi有没有类似于C的memset函数的东东,期待
- 求用Delphi测试多台远程计算机的连接问题?
- 奇怪啊,我去年的帖子就结了啊,怎么还扣信誉分?版主给个说明。
- 请问ADOCommand,ADODataSet,ADOQuery这点个DD有什么区别啊????
- 100分求corba例子,目的是了解其接口实现!!
- 请各位大侠帮忙, 修改光标
- 如何在程序或vxd中实现暂停其他程序的运行?
- 一个类的小问题。
要求:1.装有BDE
2.自己先配置好ODBC与数据库的连接
3.运行...