I
isdongyue
Unregistered / Unconfirmed
GUEST, unregistred user!
大虾:
我做了一个Data Module ,里面放入TADOConnection和TADOTable各一个,存取数据库
,将这个Data Module加入到一个application中可以正常执行,但加入到一个Active server Object
project(asp)中则出现异常,不知能解释否 。
部分代码如下:
Data_Module部分
unit Data_Module;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, ADODB;
type
TDataModule1 = class(TDataModule)
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
private
{ Private declarations }
public
{ Public declarations }
procedure get_data(theID:integer);
end;
var
DataModule1: TDataModule1;
// para:array[1..3]of double;
implementation
{$R *.DFM}
procedure TDataModule1.get_data(theID:integer);
begin
if ADOConnection1.Connected=false then
ADOConnection1.Connected:=true;
if ADOTable1.Active=false then
begin
ADOTable1.TableName:='ID';
ADOTable1.Active:=true;
end;
// para[1]:=x;
// para[2]:=y;
// para[3]:=z;
ADOTable1.Locate('sessionID',theID,[loCaseInsensitive]);
ADOTable1.Edit;
ADOTable1.Fields.Fields[1].AsFloat:=5000;
ADOTable1.Post;
end;
end.
Active server object 实现unit
unit ASP_object;
interface
uses
ComObj, ActiveX, AspTlb, Project2_TLB, StdVcl;
type
Tasptest1 = class(TASPMTSObject, Iasptest1)
protected
function getdata(sid: Integer): Integer
safecall;
end;
implementation
uses ComServ,unit1;
function Tasptest1.getdata(sid: Integer): Integer;
begin
DataModule1.get_data(sid);
result:=1;
end;
initialization
TAutoObjectFactory.Create(ComServer, Tasptest1, Class_asptest1,
ciMultiInstance, tmApartment);
end.
asp文件 test.asp
<HTML>
<BODY>
<TITLE> Testing Delphi ASP </TITLE>
<CENTER>
<H3> You should see the results of your Delphi Active Server method below </H3>
</CENTER>
<HR>
<%
dim te_value
dim theId
theId=Session.SessionID
Set DelphiASPObj = Server.CreateObject("Project2.asptest1")
te_value=DelphiASPObj.getdata(theId)
Response.write "value is "&te_value
%>
<HR>
</BODY>
</HTML>
test.asp中创建delphi active server object对象,然后调用Interface,但总是在unit ASP_object调用
unit Data_Module的函数如procedure TDataModule1.get_data(theID:integer);时总出错,似乎是delphi
的TAdoconnection与Tadotable不能执行,(我用异常处理try..except..试过)。
请指教
谢谢。
另外,不知你用过asp component的调试没有,帮助上说在run|parameter的Host applicatiion
box中添入web server name,我用的是iis5,应添入什么呀?
我做了一个Data Module ,里面放入TADOConnection和TADOTable各一个,存取数据库
,将这个Data Module加入到一个application中可以正常执行,但加入到一个Active server Object
project(asp)中则出现异常,不知能解释否 。
部分代码如下:
Data_Module部分
unit Data_Module;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, ADODB;
type
TDataModule1 = class(TDataModule)
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
private
{ Private declarations }
public
{ Public declarations }
procedure get_data(theID:integer);
end;
var
DataModule1: TDataModule1;
// para:array[1..3]of double;
implementation
{$R *.DFM}
procedure TDataModule1.get_data(theID:integer);
begin
if ADOConnection1.Connected=false then
ADOConnection1.Connected:=true;
if ADOTable1.Active=false then
begin
ADOTable1.TableName:='ID';
ADOTable1.Active:=true;
end;
// para[1]:=x;
// para[2]:=y;
// para[3]:=z;
ADOTable1.Locate('sessionID',theID,[loCaseInsensitive]);
ADOTable1.Edit;
ADOTable1.Fields.Fields[1].AsFloat:=5000;
ADOTable1.Post;
end;
end.
Active server object 实现unit
unit ASP_object;
interface
uses
ComObj, ActiveX, AspTlb, Project2_TLB, StdVcl;
type
Tasptest1 = class(TASPMTSObject, Iasptest1)
protected
function getdata(sid: Integer): Integer
safecall;
end;
implementation
uses ComServ,unit1;
function Tasptest1.getdata(sid: Integer): Integer;
begin
DataModule1.get_data(sid);
result:=1;
end;
initialization
TAutoObjectFactory.Create(ComServer, Tasptest1, Class_asptest1,
ciMultiInstance, tmApartment);
end.
asp文件 test.asp
<HTML>
<BODY>
<TITLE> Testing Delphi ASP </TITLE>
<CENTER>
<H3> You should see the results of your Delphi Active Server method below </H3>
</CENTER>
<HR>
<%
dim te_value
dim theId
theId=Session.SessionID
Set DelphiASPObj = Server.CreateObject("Project2.asptest1")
te_value=DelphiASPObj.getdata(theId)
Response.write "value is "&te_value
%>
<HR>
</BODY>
</HTML>
test.asp中创建delphi active server object对象,然后调用Interface,但总是在unit ASP_object调用
unit Data_Module的函数如procedure TDataModule1.get_data(theID:integer);时总出错,似乎是delphi
的TAdoconnection与Tadotable不能执行,(我用异常处理try..except..试过)。
请指教
谢谢。
另外,不知你用过asp component的调试没有,帮助上说在run|parameter的Host applicatiion
box中添入web server name,我用的是iis5,应添入什么呀?