以前的回答
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
%>