我把部分代码贴出来,大家帮我看看错哪了:
底层数据模块:
procedure TTempLessonDM.MtsDataModuleActivate(Sender: TObject);
begin
TempLessonADO.Connected := true;//TempLessonADO:TADOConnection
GetTempLessonByClassNo.Active := true;//GetTempLessonByClassNo: TADOStoredProc;
end;
procedure TTempLessonDM.MtsDataModuleDeactivate(Sender: TObject);
begin
TempLessonADO.Connected := false;
GetTempLessonByClassNo.Active := false;
end;
中间层:
procedure TTempLessonMTS.GetTempLessonPage(const Number, StarTerm,
EndTerm: WideString;
isLike, iType: SYSINT;
var ReturnPage: WideString);
begin
if iType=0 then
begin
TempLessonDM.GetTempLessonBroker.ProviderName := 'GetTempLessonByClassNoDP';
//TempLessonDM:TDataModel,GetTempLessonBroker:TXMLBroker,根据不同的入口参数,
//给GetTempLessonBroker连接不同的datasetprovider,
TempLessonDM.GetTempLessonBroker.FetchParams ;//刷新存储过程所带的参数,在这我发现刷新 时自动激活MIDASConnection,所以我就不再激活它!
TempLessonDM.GetTempLessonBroker.Params.ParamByName('@ClassNo').asstring:= Number;
end
else
if iType=1 then
begin
TempLessonDM.GetTempLessonBroker.ProviderName := 'GetTempLessonBySubjectNoDP';
TempLessonDM.GetTempLessonBroker.FetchParams ;
TempLessonDM.GetTempLessonBroker.Params.ParamByName('@SubjectNo').asstring:= Number;
end
else
if iType=2 then
begin
TempLessonDM.GetTempLessonBroker.ProviderName := 'GetTempLessonByTeacherNoDP';
TempLessonDM.GetTempLessonBroker.FetchParams ;
TempLessonDM.GetTempLessonBroker.Params.ParamByName('@TeacherNo').asstring:= Number;
end;
TempLessonDM.GetTempLessonBroker.Params.ParamByName('@StarTerm').asstring:= StarTerm;
TempLessonDM.GetTempLessonBroker.Params.ParamByName('@EndTerm').asstring:= EndTerm;
TempLessonDM.GetTempLessonBroker.Params.ParamByName('@isLike').asinteger:= islike;
TempLessonDM.GetTempLessonBroker.Connected := true;
ReturnPage := TempLessonDM.GetTempLessonPage.Content;
// TempLessonDM.TempLessonDCOM.Connected := false;
end;
procedure TTempLessonMTS.ApplyUpdateTempLesson(const Delta: WideString;
var iErrorCount: Integer);//中间层提交数据接口过程
begin
TempLessonDM.GetTempLessonBroker.ApplyXMLUpdates(Delta,iErrorCount);
end;
第一层:
function TTempLessonAsp.GetDeltaPacket: String;//取得数据封包
begin
Result := Request.Form.Item['postdelta'];
end;
procedure TTempLessonAsp.GetTempLessonPage(const Number, StarTerm,
EndTerm: WideString;
isLike, iType: SYSINT);
var
Obj : variant;
TempLessonPage : WideString;
begin
Obj := Server.CreateObject('TempLessonMTS_Dpr.TempLessonMTS');//TempLessonMTS_Dpr是中间层的工程名
//TempLessonMTS是它的接口名称
Obj.GetTempLessonPage(Number, StarTerm, EndTerm, isLike, iType, TempLessonPage);
Response.Write(TempLessonPage);
end;
function TTempLessonAsp.ApplyTempLesson: Integer;
var
Obj : variant;
ErrorCount : integer;
begin
Obj := Server.CreateObject('TempLessonMTS_Dpr.TempLessonMTS');
Obj.ApplyUpdateTempLesson(GetDeltaPacket, ErrorCount);//调用中间层的接口过程!
Result := ErrorCount;
end;
第一层生成的ASP文件:
<%@Language = javascript %>
<HTML>
<BODY>
<TITLE> Testing Delphi ASP </TITLE>
<CENTER>
<H3> You should see the results of your Delphi Active Server method below </H3>
</CENTER>
<HR>
<%
function isapplyupdatesuequest() //判断是否有Delta数据封包
{
return (Request.Form("postdelta").count>0);
};
var TempLessonASPObj,Number = '%', StarTerm = '000000000', EndTerm = '999999999', isLike = 1, iType = 0;
function CreateASPObj() //建立TempLessonAsp对象
{
if (this.TempLessonAspObj == null)
TempLessonAspObj = Server.CreateObject("TempLessonAsp_D.TempLessonAsp");
return TempLessonAspObj;
};
// TempLessonAspObj = Server.CreateObject("TempLessonAsp_D.TempLessonAsp");
CreateASPObj().GetTempLessonPage(Number,StarTerm,EndTerm,isLike,iType);
if (Request.Form("postdelta").count>0)
{
CreateASPObj().ApplyTempLesson();
}
%>
<HR>
</BODY>