H
huapoint
Unregistered / Unconfirmed
GUEST, unregistred user!
服务端:
unit Unit2;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
DBClient, Project1_TLB, StdVcl, DB, ADODB, Provider;
type
THrserv = class(TRemoteDataModule, IHrserv)
ADOConnection1: TADOConnection;
DataSetProvider1: TDataSetProvider;
ADOQuery1: TADOQuery;
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
procedure Logined(bAliasName, aPassword: OleVariant; var aYhbh, aZH,
aLogined: OleVariant); safecall;
public
{ Public declarations }
end;
implementation
{$R *.DFM}
class procedure THrserv.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure THrserv.Logined(bAliasName, aPassword: OleVariant; var aYhbh, aZH,
aLogined: OleVariant);
var
sqlString: string;
begin
aLogined := True;
//用SQL语句来判断身份是否存在
sqlString := 'select * from abc where UNum=' + '''' + bAliasName + ''' and ';
sqlString := sqlString + ' Pass=' + '''' + aPassword + '''';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sqlString);
try
adoquery1.Open;
except
aLogined := False;
exit;
end;
if adoquery1.RecordCount = 0 then //查到记录为O,代表身份不存在
begin
aLogined := False;
exit;
end;
end;
initialization
TComponentFactory.Create(ComServer, THrserv,
Class_Hrserv, ciMultiInstance, tmApartment);
end.
客户端:
procedure THRClint.Button1Click(Sender: TObject);
var
vYhbh, vZh: variant;
vLogined: variant;
vAliasName, vPassword: string;
begin
vAliasName := edit1.text;
vPassword := edit2.Text;
HRClint.DCOMConnection1.AppServer.Logined(vAliasName, vPassword, vYhbh, vzh, vLogined);
if not vLogined then
begin
Application.MessageBox('用户名和密码不正确,请重新输入', '提示信息', mb_iconInformation + mb_defbutton1);
exit;
end;
end;
end.
报 Metheod 'Logined' not supported by automation object.错误。
请高手指点。谢谢!
unit Unit2;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
DBClient, Project1_TLB, StdVcl, DB, ADODB, Provider;
type
THrserv = class(TRemoteDataModule, IHrserv)
ADOConnection1: TADOConnection;
DataSetProvider1: TDataSetProvider;
ADOQuery1: TADOQuery;
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
procedure Logined(bAliasName, aPassword: OleVariant; var aYhbh, aZH,
aLogined: OleVariant); safecall;
public
{ Public declarations }
end;
implementation
{$R *.DFM}
class procedure THrserv.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure THrserv.Logined(bAliasName, aPassword: OleVariant; var aYhbh, aZH,
aLogined: OleVariant);
var
sqlString: string;
begin
aLogined := True;
//用SQL语句来判断身份是否存在
sqlString := 'select * from abc where UNum=' + '''' + bAliasName + ''' and ';
sqlString := sqlString + ' Pass=' + '''' + aPassword + '''';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sqlString);
try
adoquery1.Open;
except
aLogined := False;
exit;
end;
if adoquery1.RecordCount = 0 then //查到记录为O,代表身份不存在
begin
aLogined := False;
exit;
end;
end;
initialization
TComponentFactory.Create(ComServer, THrserv,
Class_Hrserv, ciMultiInstance, tmApartment);
end.
客户端:
procedure THRClint.Button1Click(Sender: TObject);
var
vYhbh, vZh: variant;
vLogined: variant;
vAliasName, vPassword: string;
begin
vAliasName := edit1.text;
vPassword := edit2.Text;
HRClint.DCOMConnection1.AppServer.Logined(vAliasName, vPassword, vYhbh, vzh, vLogined);
if not vLogined then
begin
Application.MessageBox('用户名和密码不正确,请重新输入', '提示信息', mb_iconInformation + mb_defbutton1);
exit;
end;
end;
end.
报 Metheod 'Logined' not supported by automation object.错误。
请高手指点。谢谢!
代码: