现在这个问题解决了,但是,连接上去后,又出现“找不到成员”的错误
客户端代码是这样:
if not SocketConnection1.AppServer.checklogin(edit1.text,edit2.Text) then
showmessage(SocketConnection1.AppServer.Err_Msg)
else
showmessage('登录成功');
checklogin是MTS中的一个只读属性,两个输入参数为Bstr,返回值为Boolean;
err_msg也是MTS中的一个只读属性,返回值为Bstr
不知程序有何问题?
server端代码
===========================================================================
unit crm_server_com_scr;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, BdeMts, DataBkr, DBClient,
MtsRdm, Mtx, crm_server_com_TLB, Db, ADODB, Provider;
type
TCrmSvr = class(TMtsDataModule, ICrmSvr)
LogRS: TADODataSet;
Prov1: TDataSetProvider;
conn: TADOConnection;
private
FErr_Msg : string;
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
function Get_checklogin(const username, password: WideString): WordBool;
safecall;
function Get_Err_Msg: WideString; safecall;
public
{ Public declarations }
end;
var
CrmSvr: TCrmSvr;
implementation
{$R *.DFM}
class procedure TCrmSvr.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;
function TCrmSvr.Get_checklogin(const username,
password: WideString): WordBool;
begin
conn.CursorLocation := clUseClient;
if not conn.Connected then conn.Connected:=true;
if LogRS.Active then LogRS.Close;
LogRS.Parameters[0].Value:=username;
try
LogRS.Open;
if LogRS.Eof then
begin
FErr_Msg := '用户名错误。';
result := false;
LogRS.Close;
exit;
end
else
begin
if (LogRS.Fields[2].value <> password) then
begin
FErr_Msg := '密码错误。';
result := false;
LogRS.Close;
exit;
end
else
begin
result := true;
LogRS.Close;
end;
end;
finally
LogRS.Close;
end;
end;
function TCrmSvr.Get_Err_Msg: WideString;
begin
result := FErr_Msg;
end;
initialization
TComponentFactory.Create(ComServer, TCrmSvr,
Class_CrmSvr, ciMultiInstance, tmApartment);
end.