DELPHI 三层问题???急!!!!!(20分)

  • 主题发起人 主题发起人 huapoint
  • 开始时间 开始时间
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.错误。
请高手指点。谢谢!
代码:
 
呵呵..正在学习中..

可以给一个简单的例子学习下吗?

偶的邮箱:wsc188@126.com

多谢..
 
学习!

看LZ的错误提示好象是
HRClint.DCOMConnection1.AppServer.Logined(vAliasName, vPassword, vYhbh, vzh, vLogined); 有错! 是不是?
 
com 沒有 注冊
 
把这一段:
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

改成:
procedure Logined(bAliasName, aPassword: OleVariant; var aYhbh, aZH,
aLogined: OleVariant); safecall;
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
public
试一试!
 
谢谢了。
 
非常感谢。那问题已经解决。现在出现的问题是我的服务端放XP系统下。局域网内没任何问题。但是我把服务端放2000 Server 和 2003 Server上在网内访问不了。还有就是在服务端放外网同样是访问不了。不知道什么原因。使用的是SoketServer。请高手指教...
 
后退
顶部