A
amartapple
Unregistered / Unconfirmed
GUEST, unregistred user!
下面很长,希望您仔细看,不管您解决是否,我想通过大家的讨论你总能学些东西,不管你说的对不对,希望你把知道的都说出来,谢谢,我调了一天了,实在不行了,
1、新建一个 ActiveX Library -名称为:Soft
2、再建一个 Active Server Object -名称为:TodayTop(TodayTop10.pas)
3、再建一个 Data Module
4、在 Data Module 中放入一个 ADOConnection 连接数据库,成功。再放入一个ADOQuery,设置它的Connection为ADOConnection
5、然后在TodayTop中加入一个GetTop10的方法
6、这是TodayTop的代码
//------------------------------------------------------------------------------
unit TodayTopPas;
//------------------------------------------------------------------------------
{$WARN SYMBOL_PLATFORM OFF}
//------------------------------------------------------------------------------
interface
//------------------------------------------------------------------------------
uses
ComObj, ActiveX, AspTlb, soft_TLB, StdVcl, DM1, SysUtils;
//------------------------------------------------------------------------------
type
TTodayTop = class(TASPObject, ITodayTop)
private
FDM:TDM;
protected
procedure OnEndPage; safecall;
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure GetTop10; safecall;
public
procedure Initialize;override;
destructor Destroy;override;
end;
//------------------------------------------------------------------------------
implementation
//------------------------------------------------------------------------------
uses ComServ, Forms;
//------------------------------------------------------------------------------
//加载数据模块
procedure TTodayTop.Initialize;
begin
inherited;
FDM:=TDM.Create(Forms.Application);
end;
//------------------------------------------------------------------------------
//释放数据模块
destructor TTodayTop.Destroy;
begin
inherited;
FDM.Free;
end;
//------------------------------------------------------------------------------
procedure TTodayTop.OnEndPage;
begin
inherited OnEndPage;
end;
//------------------------------------------------------------------------------
procedure TTodayTop.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;
//------------------------------------------------------------------------------
procedure TTodayTop.GetTop10;
var
TodayDate:String;
begin
TodayDate:=DateToStr(Date);
With DM.ADOQuery1 do
begin
{Close;
Sql.Clear;
Sql.Add('select top 10 id,showname,bb from download '+
'where lasthits='''+TodayDate+''' and stop=0 and '+
'dayhits>0 order by dayhits desc');
Open;
Response.Write('<table width="99%" border="1">');
Response.Write('<tr>');
if(Eof and Bof)then
begin
Response.Write('<td>');
Response.Write('本日没有下载');
Response.Write('</td>');
end
else
begin
While not Eof do
begin
Response.Write('<td>');
Response.Write('<li><A href=list.asp?id='''+FieldByname('id').Value+'''>');
Response.Write(FieldByname('ShowName').Value+' '+FieldByname('bb').Value);
Response.Write('</A></li>');
Response.Write('</td>');
Next;
end;
end;
Response.Write('</tr>');
Response.Write('</table>');}
end;
end;
//------------------------------------------------------------------------------
initialization
TAutoObjectFactory.Create(ComServer, TTodayTop, Class_TodayTop,
ciMultiInstance, tmApartment);
//------------------------------------------------------------------------------
end.
//------------------------------------------------------------------------------
7、编译生成 Soft.dll 文件
8、在 TodayTopAsp.asp 中调用这个对象,如下:
//------------------------------------------------------------------------------
<%@language=Jscript%>
<HTML>
<BODY>
<TITLE> Testing Delphi ASP </TITLE>
<CENTER>
<H3> You should see the results of your Delphi Active Server method below </H3>
</CENTER>
<HR>
<%
var DelphiASPObj;
DelphiASPObj = Server.CreateObject("soft.TodayTop");
DelphiASPObj.GetTop10();
%>
<HR>
</BODY>
</HTML>
//------------------------------------------------------------------------------
9、用iis搭建服务器,访问出现错误 500.100
请大家仔细看看,帮我查查原因,非常感谢
1、新建一个 ActiveX Library -名称为:Soft
2、再建一个 Active Server Object -名称为:TodayTop(TodayTop10.pas)
3、再建一个 Data Module
4、在 Data Module 中放入一个 ADOConnection 连接数据库,成功。再放入一个ADOQuery,设置它的Connection为ADOConnection
5、然后在TodayTop中加入一个GetTop10的方法
6、这是TodayTop的代码
//------------------------------------------------------------------------------
unit TodayTopPas;
//------------------------------------------------------------------------------
{$WARN SYMBOL_PLATFORM OFF}
//------------------------------------------------------------------------------
interface
//------------------------------------------------------------------------------
uses
ComObj, ActiveX, AspTlb, soft_TLB, StdVcl, DM1, SysUtils;
//------------------------------------------------------------------------------
type
TTodayTop = class(TASPObject, ITodayTop)
private
FDM:TDM;
protected
procedure OnEndPage; safecall;
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure GetTop10; safecall;
public
procedure Initialize;override;
destructor Destroy;override;
end;
//------------------------------------------------------------------------------
implementation
//------------------------------------------------------------------------------
uses ComServ, Forms;
//------------------------------------------------------------------------------
//加载数据模块
procedure TTodayTop.Initialize;
begin
inherited;
FDM:=TDM.Create(Forms.Application);
end;
//------------------------------------------------------------------------------
//释放数据模块
destructor TTodayTop.Destroy;
begin
inherited;
FDM.Free;
end;
//------------------------------------------------------------------------------
procedure TTodayTop.OnEndPage;
begin
inherited OnEndPage;
end;
//------------------------------------------------------------------------------
procedure TTodayTop.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;
//------------------------------------------------------------------------------
procedure TTodayTop.GetTop10;
var
TodayDate:String;
begin
TodayDate:=DateToStr(Date);
With DM.ADOQuery1 do
begin
{Close;
Sql.Clear;
Sql.Add('select top 10 id,showname,bb from download '+
'where lasthits='''+TodayDate+''' and stop=0 and '+
'dayhits>0 order by dayhits desc');
Open;
Response.Write('<table width="99%" border="1">');
Response.Write('<tr>');
if(Eof and Bof)then
begin
Response.Write('<td>');
Response.Write('本日没有下载');
Response.Write('</td>');
end
else
begin
While not Eof do
begin
Response.Write('<td>');
Response.Write('<li><A href=list.asp?id='''+FieldByname('id').Value+'''>');
Response.Write(FieldByname('ShowName').Value+' '+FieldByname('bb').Value);
Response.Write('</A></li>');
Response.Write('</td>');
Next;
end;
end;
Response.Write('</tr>');
Response.Write('</table>');}
end;
end;
//------------------------------------------------------------------------------
initialization
TAutoObjectFactory.Create(ComServer, TTodayTop, Class_TodayTop,
ciMultiInstance, tmApartment);
//------------------------------------------------------------------------------
end.
//------------------------------------------------------------------------------
7、编译生成 Soft.dll 文件
8、在 TodayTopAsp.asp 中调用这个对象,如下:
//------------------------------------------------------------------------------
<%@language=Jscript%>
<HTML>
<BODY>
<TITLE> Testing Delphi ASP </TITLE>
<CENTER>
<H3> You should see the results of your Delphi Active Server method below </H3>
</CENTER>
<HR>
<%
var DelphiASPObj;
DelphiASPObj = Server.CreateObject("soft.TodayTop");
DelphiASPObj.GetTop10();
%>
<HR>
</BODY>
</HTML>
//------------------------------------------------------------------------------
9、用iis搭建服务器,访问出现错误 500.100
请大家仔细看看,帮我查查原因,非常感谢