MTS的问题:(100分)

  • 主题发起人 主题发起人 Dephic
  • 开始时间 开始时间
D

Dephic

Unregistered / Unconfirmed
GUEST, unregistred user!
如何在MTS Object 中创建MTS DataModule实例?(注:不是用DCOMConnection连接)
我写的代码:
function TInfoSendQuery.GetNewInfo(const sWorkNo,
sisRead: WideString): WideString;
var
InfoSend : IInfoSendDM;
begin
try
OleCheck(ObjectContext.CreateInstance(CLASS_InfoSendDM,IID_IInfoSendDM,InfoSend));
result := InfoSend.
GetNewInfo(sWorkNo,sisRead);//执行到此句的时候出错!需要一个连接DLL的错!
InfoSend := nil;
setcomplete;
except
setabort;
raise;
end;
end;

谁能告诉我如何正确的创建呢?
 
以前的回答
addie (2000-12-04 18:53:00)
TypeLibary中的部分代码(由Delphi自动生成):
IUserInfo = interface(IAppServer)
['{4CA2EFDF-C551-4E5B-949E-27281A7F6BA9}']
function Get_Information: Recordset;
safecall;
procedure GetAll;
safecall;
function Login(const UserName: WideString;
const Password: WideString): WordBool;
safecall;
function QueryByID(UserID: Integer): WordBool;
safecall;
function QueryByName(const UserName: WideString): WordBool;
safecall;
property Information: Recordset read Get_Information;
end;

DataModule中的部分实现代码:
Uses
Window......, ADODB, ADODB_TLB;
//顺序不能错。
type
TUserInfo = class(TMtsDataModule, IUserInfo)
Conn: TADOConnection;
qyLogin: TADOQuery;
qyByID: TADOQuery;
qyByName: TADOQuery;
tbAll: TADOTable;
private
FRecordSet: TCustomADODataSet;
protected
class procedure UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
override;
procedure GetAll;
safecall;
function Get_Information: Recordset;
safecall;
function Login(const UserName: WideString;
const Password: WideString): WordBool;
safecall;
function QueryByID(UserID: Integer): WordBool;
safecall;
function QueryByName(const UserName: WideString): WordBool;
safecall;
public
end;
....

function TUserInfo.Get_Information: Recordset;
begin
Result := _RecordSet(FRecordSet.RecordSet);
// _RecordSet 为ADODB_TLB._RecordSet, 所以在Uses中的顺序不能错。
end;

function TUserInfo.Login(const UserName, Password: WideString): WordBool;
begin
with qyLogindo
begin
Close;
Parameters[0].Value := UserName;
Parameters[1].Value := Password;
Open;
Result := not (Bof and Eof);
end;
FRecordSet := qyLogin;
end;
....
end.

ASP调用代码:
<%
dim MyLogin
Set MyLogin = Server.CreateObject("xxLib.UserInfo")
if MyLogin.Login("addie", "chenjin") then
Response.write MyLogin.Information.Fields("FullName").Value
else
Response.Write "Login Failed"
end if
%>

 
接受答案了.
 
后退
顶部