在MTS中如何返回记录型数组?在ASP中如何读取它?(200分)

  • 主题发起人 主题发起人 Annie
  • 开始时间 开始时间
A

Annie

Unregistered / Unconfirmed
GUEST, unregistred user!
我需要在MTS中返回一组packed record给oleVariant变量,不知如何实现?
返回后需在ASP页面中读取这组数据,请问如何实现?
 
如果返回RECORDSET不如在ASP中直接用ADO来取得,不知道你到底需要回传
什么样的记录型数组?
 
yu gao:
type TMyType = packed record
i:integer;
s:String;
end;
就是类似的东西叫记录,呵呵
Annie:我一般不用记录类型,而是返回字串,定义自己的格式!
实际上,如果你是记录类型,理论上,可以直接在ASP拆开,比如我上面的记录,前4位
是整型数字,后面就是字串。具体没式过。
 
实际上,如果你返回的是对象,那么直接访问对象里的属性不好吗?为什么要返回记录呢?
 
如果要返回Recordset的话,可以试一下这种方法:
Server:
导入MS的ADO
user adodb_tlb,
Result:=iunknown(DataModule.AdoQuery.Execute) as Recordset;
这样客户段如果是asp的话,那么可以直接调用
 
我也在问这个问题,用数组的话,图片文件如何处理,yaodong的可行吗?
 
不是Recordset,而是用Winsock与另一台机器(单片机之类的)通信后获得的一组结构数组,
不知CJ有何高招?
 
用asp.net可以
 
可以这样定义
代码:
接口:
IUser = interface(IUnknown)
    ['{51299263-DF5E-4723-B4F7-05BFC6800DF4}']
    function Get_UserName: WideString;
safecall;
    procedure Set_UserName(const Value: WideString);
safecall;
    function Get_ID: Integer;
safecall;
    procedure Set_ID(Value: Integer);
safecall;
    function Get_ChaName: WideString;
safecall;
    procedure Set_ChaName(const Value: WideString);
safecall;
    function Get_EngName: WideString;
safecall;
    procedure Set_EngName(const Value: WideString);
safecall;
    function Get_Password: WideString;
safecall;
    procedure Set_Password(const Value: WideString);
safecall;
    function Get_Cookie: WideString;
safecall;
    procedure Set_Cookie(const Value: WideString);
safecall;
    function Get_IP: WideString;
safecall;
    procedure Set_IP(const Value: WideString);
safecall;
    function Get_DepartmentID: Integer;
safecall;
    procedure Set_DepartmentID(Value: Integer);
safecall;
    function Get_DepartmentName: WideString;
safecall;
    procedure Set_DepartmentName(const Value: WideString);
safecall;
    property UserName: WideString read Get_UserName write Set_UserName;
    property ID: Integer read Get_ID write Set_ID;
    property ChaName: WideString read Get_ChaName write Set_ChaName;
    property EngName: WideString read Get_EngName write Set_EngName;
    property Password: WideString read Get_Password write Set_Password;
    property Cookie: WideString read Get_Cookie write Set_Cookie;
    property IP: WideString read Get_IP write Set_IP;
    property DepartmentID: Integer read Get_DepartmentID write Set_DepartmentID;
    property DepartmentName: WideString read Get_DepartmentName write Set_DepartmentName;
  end;
  IUsers = interface(IDispatch)
    ['{8AA6BBD6-BA63-436D-AD02-9A7C2BD415E8}']
    function New: IUser;
safecall;
    procedure Delete(Index: Integer);
safecall;
    procedure Clear;
safecall;
    function Add(const Item: IUser): Integer;
safecall;
    function IndexOf(const aCookie: WideString): Integer;
safecall;
    function AddUser(const Item: IUser): Integer;
safecall;
    function Get_Count: Integer;
safecall;
    function Get_Item(const aCookie: WideString): IUser;
safecall;
    function GetItem(Index: Integer;
const Password: WideString): IUser;
safecall;
    property Count: Integer read Get_Count;
    property Item[const aCookie: WideString]: IUser read Get_Item;
  end;
 
实现:
TUser = class(TInterfacedObject, IUser)
private
FID: Integer;
FUserName: string;
FPassword: string;
FChaName: string;
FEngName: string;
FCookie: string;
FIP: string;
FDepartID: Integer;
FDepartName: string;
FEditor: Boolean;
protected
function Get_Editor: WordBool;
safecall;
procedure Set_Editor(Value: WordBool);
safecall;
function Get_UserName: WideString;
safecall;
procedure Set_UserName(const Value: WideString);
safecall;
function Get_ID: Integer;
safecall;
procedure Set_ID(Value: Integer);
safecall;
function Get_ChaName: WideString;
safecall;
procedure Set_ChaName(const Value: WideString);
safecall;
function Get_EngName: WideString;
safecall;
procedure Set_EngName(const Value: WideString);
safecall;
function Get_Password: WideString;
safecall;
procedure Set_Password(const Value: WideString);
safecall;
function Get_Cookie: WideString;
safecall;
procedure Set_Cookie(const Value: WideString);
safecall;
function Get_IP: WideString;
safecall;
procedure Set_IP(const Value: WideString);
safecall;
function Get_DepartmentID: Integer;
safecall;
procedure Set_DepartmentID(Value: Integer);
safecall;
function Get_DepartmentName: WideString;
safecall;
procedure Set_DepartmentName(const Value: WideString);
safecall;
public
property UserName: WideString read Get_UserName write Set_UserName;
property ID: Integer read Get_ID write Set_ID;
property ChaName: WideString read Get_ChaName write Set_ChaName;
property EngName: WideString read Get_EngName write Set_EngName;
property Password: WideString read Get_Password write Set_Password;
property Cookie: WideString read Get_Cookie write Set_Cookie;
property IP: WideString read Get_IP write Set_IP;
property DepartmentID: Integer read Get_DepartmentID write Set_DepartmentID;
property DepartmentName: WideString read Get_DepartmentName write
Set_DepartmentName;
property Editor: WordBool read Get_Editor write Set_Editor;
end;

TUsers = class(TInterfacedObject, IUsers)
private
FList: TInterfaceList;
procedure InitUsers;
protected
function Add(const Item: IUser): Integer;
safecall;
function AddUser(const Item: IUser): Integer;
safecall;
function Get_Count: Integer;
safecall;
function Get_Item(const aCookie: WideString): IUser;
safecall;
function GetItem(Index: Integer;
const Password: WideString): IUser;
safecall;
function IndexOf(const aCookie: WideString): Integer;
safecall;
function New: IUser;
safecall;
procedure Clear;
safecall;
procedure Delete(Index: Integer);
safecall;
{ Protected declarations }
public
end;
 
var
obj : IUsers ;
i : Integer;
begin

for i:= 0 to obj.Count -1do
with obj.getitem(i,'******')do

Memo1.Lines.Add(Format('ID:%d,User:%s,ChaName:%s,EngName:%s,DepartID:%d,DepatName:%s,Cookie:%s'
,[ID,UserName,ChaName,EngName,DepartmentID,DepartmentName,Cookie]));
end;
请根据实际情更改。此法肯定可以行。我已经试过了,Asp,ASP.NET,C#里都可以用
 
接受答案了.
 
后退
顶部