我用delphi写了一个ActiveX DLL,生成DLL时是没有错的,在asp中调用的时时候,出错信息为“ 错误类型:Method1.soar (0x8000FFFF) /saor.asp, 第 12 行”,其中第 12 行为DelphiASPObj.Method1("soardom")。其中调用属性和一般的方法(不涉及数据库)是没有错误的
asp代码为
<% Set DelphiASPObj = Server.CreateObject("Method1.soar")
response.write DelphiASPObj.Tuser &
"<BR><BR>"
DelphiASPObj.Tuser = "soardom"
response.write DelphiASPObj.Tuser &
"<BR><BR>"
DelphiASPObj.Method1("soardom") //为第12行
response.write DelphiASPObj.Tuser &
"<BR><BR>"
set DelphiASPObj = nothing
%>
////////////////////////////////////////////////////////////////
delhpi 代码为
unit Unit1;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, Method1_TLB, StdVcl, Unit2;
type
Tsoar = class(TASPObject, Isoar)
private
SNametmp : string;
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
function Get_Tuser: WideString
safecall;
procedure Method1(const SName: WideString)
safecall;
procedure Set_Tuser(const Value: WideString)
safecall;
end;
implementation
uses ComServ;
procedure Tsoar.OnEndPage;
begin
inherited OnEndPage;
end;
procedure Tsoar.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
SNametmp := '测试用';
end;
function Tsoar.Get_Tuser: WideString;
begin
Result := SNametmp;
end;
procedure Tsoar.Method1(const SName: WideString);
var
DM : TDataModule2;
begin
DM := TDataModule2.Create(nil);
try
DM.Query1.Close;
DM.Query1.SQL.Clear;
DM.Query1.SQL.Add('select * from SUser where SName = :value0');
DM.Query1.Params[0].AsString := string(SName);
DM.Query1.Prepare;
DM.Query1.Open;
if DM.Query1.RecordCount = 0 then
SNametmp := '该用户不存在'
else
SNametmp := '该用户的权限为' + DM.Query1.FieldByName('Authority').AsString;
finally
DM.Free;
end;
end;
procedure Tsoar.Set_Tuser(const Value: WideString);
begin
SNametmp := Value;
end;
initialization
TAutoObjectFactory.Create(ComServer, Tsoar, Class_soar,
ciMultiInstance, tmApartment);
end.