{以下是(WEB应用程序)程序的部分代码,请指教,指出错误是在注释区}unit sycWebMainUnit;interface uses Windows, Messages, SysUtils, Classes, HTTPApp, Db, ADODB; ... ...procedure TWebModule1.WebModule1ActionListAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); var ftype,sign,name,show,page,MaxCount, endType,listUrl,modiCount:string; yy,mm,dd:word; i,stint:int64; j,r:integer; begin { 文件资料列表 用法:Read.dll/List[?[title=nTitle][type=nType&][item=nItem&][name=nName&][show=1][MaxCount=X][page=N]] 参数说明: title=nTitle : 显示标题 type=nType: 0时, 所有资料,其他值时,查寻文件类型范围为范围匹配 nType=0时,查寻所有文件类型 当type=字符串时,查出ID,当作TYPE endType=eType: 查询下限范围类型ID号或名称(规则同type) iType=ID1;ID2;...IDn: 文件类型ID列表,形如//错误指示停在此行,提示:Line too long(more than 1023 characters)” name=nName: 指定文件所属用户的ID号或名称 sign=1: 精确匹配type指定的ID号或名称 show=1: 查找最新的资料并直接调用Read.dll?id=[nID] page=N: 按PageRecords分页的页次,当 MaxCount: 设定PageRecords参数,有此参数则page参数无效 ModiCount: } QueryReady; ftype:='';sign:='';name:='';show:='';endType:='';page:=''; listUrl:='';GuidePage:='';ModiCount:=''; ftype:=Request.QueryFields.Values['type']; endType:=Request.QueryFields.Values['endType']; sign:=Request.QueryFields.Values['sign']; name:=Request.QueryFields.Values['name']; show:=Request.QueryFields.Values['show']; page:=Request.QueryFields.Values['page']; MaxCount:=Request.QueryFields.Values['MaxCount']; ModiCount:=Request.QueryFields.Values['ModiCount']; if (page='') or (ModiCount='1') then page:='1'; //无page参数时置为默认值1 try if StrToInt(page) <=0 then page:='1'; except page:='1'; end; if MaxCount <> '' then begin//设定MaxCount时将page属性置为默认值1 if (not isIntString(MaxCount)) or (StrToInt(MaxCount) <=0) then MaxCount:=IntToStr(MaxPageRecord); end else begin MaxCount:=IntToStr(MaxPageRecord); end; if (not isIntString(ftype)) and (ftype<>'') then begin //是字符串 ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('select id from pubItem where type=''文件类型'' and content='''+ftype+''''); ADOQuery1.Open; if not ADOQuery1.IsEmpty then begin ftype:=ADOQuery1.fieldByName('id').AsString end else begin try Response.Content:=PageError.Content; Exit; except response.content:='显示网页时出错!请稍候重试'; QueryFree; ADOConnection1.Connected:=False; Handled:=True; end; end; end; ADOQuery1.Close; if (not isIntString(endType)) and (endtype<>'') then begin //是字符串 ADOQuery2.SQL.Clear; ADOQuery2.SQL.Add('select id from pubItem where type=''文件类型'' and content='''+endType+''''); ADOQuery2.Open; if not ADOQuery2.IsEmpty then endType:=ADOQuery1.fieldByName('id').AsString else endType:=''; QueryFree; end; ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('SELECT * FROM docList WHERE 1=1 '); if CompareText(name,'') <> 0 then begin ADOQuery1.SQL.Add(' AND (name=''' + name + ''' OR usr=''' + name + ''')'); end; try if (ftype<>'') and (ftype<>'999999999') then begin if CompareText(ftype,'0') <> 0 then begin if sign='1' then begin ADOQuery1.SQL.Add(' AND typeID=' + ftype); end else begin if endType='' then begin stint:=StrToInt(ftype); i:=100; while 1=1 do begin if (stint mod i) <> 0 then begin endType:=IntToStr(StrToInt(ftype)+(i div 100)); break; end else i:=i*100; end; end; ADOQuery1.SQL.Add(' AND typeID >= ' + ftype + ' AND typeID < ' + endType); end; end; end; except response.content:='数据库连接错误,请与系统管理员联系。<br>'+ftype; ADOConnection1.Connected:=False; Handled:=True; Exit; end; tagStr:=TStringList.Create; try try ADOQuery1.Prepared:=true; ADOQuery1.Open; if ADOQuery1.IsEmpty then begin tagStr.Add('<tr><td align="center"><b><br><br><br>没有更多的资料,谢谢!</b></td></tr>'); end else begin tagStr.Add('<div align="center"><center><table border=0 width="80%">'); GuidePage:=''; if (CompareText(show,'') <> 0) AND (StrToInt(show) = 1) then Response.SendRedirect(Request.ScriptName + '/read?id=' + ADOQuery1.FieldByName('ID').AsString); //定义记录位置与分页 ADOQuery1.First; j:=ADOQuery1.RecordCount div StrToInt(MaxCount);//求最大页数 if (ADOQuery1.RecordCount mod StrToInt(MaxCount))>0 then j:=j+1; ListUrl:=Request.ScriptName + '/list?'; if Request.QueryFields.Values['type'] <> '' then ListUrl:=ListUrl+'type='+Request.QueryFields.Values['type']; if Request.QueryFields.Values['endType'] <> '' then ListUrl:=ListUrl+'&endType='+Request.QueryFields.Values['endType']; if Request.QueryFields.Values['sign'] <> '' then ListUrl:=ListUrl+'&sign='+Request.QueryFields.Values['sign']; if Request.QueryFields.Values['name'] <> '' then ListUrl:=ListUrl+'&name='+Request.QueryFields.Values['name']; if Request.QueryFields.Values['show'] <> '' then ListUrl:=ListUrl+'&show='+Request.QueryFields.Values['show']; if Request.QueryFields.Values['MaxCount'] <> '' then ListUrl:=ListUrl+'&MaxCount='+Request.QueryFields.Values['MaxCount']; GuidePage:=''; GuidePage:='<table border="0" cellspacing="0" cellpadding="0"><tr><td nowrap>◎<a href="/" title="返回主页">导航</a>:'; r:=StrToInt(page); if r>j then r:=j;//r大于最大页数,溢出则回到尾页J if j>1 then begin if r=1 then begin GuidePage:=GuidePage + '<a href="'+ listUrl+'&page='+IntToStr(r+1)+'">下一页</a><font face="Webdings">8</font> ' + '<a href="'+ listUrl+'&page='+IntToStr(j)+'">尾页</a><font face="Webdings">:</font>'; end else if r=j then begin GuidePage:=GuidePage + '<font face="Webdings">9</font><a href="'+ listUrl+'&page=1">首页</a> '+ '<font face="Webdings">7</font><a href="'+ listUrl+'&page='+IntToStr(r-1)+'">上一页</a>'; end else begin GuidePage:=GuidePage + '<font face="Webdings">9</font><a href="'+ listUrl+'&page=1">首页</a> '+ '<font face="Webdings">7</font><a href="'+ listUrl+'&page='+IntToStr(r-1)+'">上一页</a> '+ '<a href="'+ listUrl+'&page='+IntToStr(r+1)+'">下一页</a><font face="Webdings">8</font> ' + '<a href="'+ listUrl+'&page='+IntToStr(j)+'">尾页</a><font face="Webdings">:</font>'; end; end; GuidePage:=GuidePage + '</td><td nowrap> 第</td><td nowrap>'+ '<form name="form1" method="GET" class="bt" action="'+ Request.ScriptName + '/list"><input type="text" size="2" class="bt" name="page" value="'+ IntToStr(r)+'">'; if Request.QueryFields.Values['type'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="type" value="'+Request.QueryFields.Values['type']+'">'; if Request.QueryFields.Values['endType'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="endType" value="'+Request.QueryFields.Values['endType']+'">'; if Request.QueryFields.Values['sign'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="sign" value="'+Request.QueryFields.Values['sign']+'">'; if Request.QueryFields.Values['name'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="name" value="'+Request.QueryFields.Values['name']+'">'; if Request.QueryFields.Values['title'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="title" value="'+Request.QueryFields.Values['title']+'">'; if Request.QueryFields.Values['show'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="type" value="'+Request.QueryFields.Values['show']+'">'; GuidePage:=GuidePage+'</form></td><td nowrap>页</td><td nowrap> [第'+ IntToStr(r)+'页/共'+IntToStr(j)+'页]</td>'; //begin 构造每页示记录数的表单 GuidePage:=GuidePage+'<td nowrap> 每页显示</td><td nowrap align="right"><form name="form2" class="bt" method="GET" action="'+ Request.ScriptName + '/list"><input type="text" name="MaxCount" class="bt" size="2" value="'+ MaxCount {IntToStr(PageRecords)}+'">'; if Request.QueryFields.Values['type'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="type" value="'+Request.QueryFields.Values['type']+'">'; if Request.QueryFields.Values['endType'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="endType" value="'+Request.QueryFields.Values['endType']+'">'; if Request.QueryFields.Values['sign'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="sign" value="'+Request.QueryFields.Values['sign']+'">'; if Request.QueryFields.Values['name'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="name" value="'+Request.QueryFields.Values['name']+'">'; if Request.QueryFields.Values['title'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="title" value="'+Request.QueryFields.Values['title']+'">'; if Request.QueryFields.Values['show'] <> '' then GuidePage:=GuidePage+'<input type="hidden" name="type" value="'+Request.QueryFields.Values['show']+'">'; GuidePage:=GuidePage+'</form></td><td nowrap>条</td></tr></table>'; //end 构造每页示记录数的表单 //定位开始显示的记录 r:=StrToInt(MaxCount) * (StrToInt(page)-1); ADOQuery1.MoveBy(r); j:=0; while (NOT ADOQuery1.Eof) and (j<StrToInt(MaxCount)) do begin DeCodeDate(ADOQuery1.FieldByName('crtDate').AsDateTime,yy,mm,dd); tagStr.Add('<tr><td><span style="font-size:5pt">● </span><a href=''' + Request.ScriptName + '/read?id=' + ADOQuery1.FieldByName('ID').AsString + '''>' + ADOQuery1.FieldByName('title').AsString + ' <i>(' + IntToStr(yy)+'-'+ IntToStr(mm) + '-' + IntToStr(dd) + ')</i></a></td></tr>'); ADOQuery1.Next; j:=j+1; end; tagStr.Add('</table></center></div>'); end; Response.Content:=PageList.Content; finally ftype:='';sign:='';name:='';show:='';endType:=''; page:='';listUrl:='';GuidePage:='';ModiCount:=''; tagStr.Free; QueryFree; ADOConnection1.Connected:=False; Handled:=True; end; except Response.Content:=ErrPage.Content; end; QueryFree; Handled:=true; end;
uses
Windows, Messages, SysUtils, Classes, HTTPApp, Db, ADODB;
...
...procedure TWebModule1.WebModule1ActionListAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
ftype,sign,name,show,page,MaxCount,
endType,listUrl,modiCount:string;
yy,mm,dd:word;
i,stint:int64;
j,r:integer;
begin
{
文件资料列表
用法:Read.dll/List[?[title=nTitle][type=nType&][item=nItem&][name=nName&][show=1][MaxCount=X][page=N]]
参数说明:
title=nTitle : 显示标题
type=nType: 0时, 所有资料,其他值时,查寻文件类型范围为范围匹配
nType=0时,查寻所有文件类型
当type=字符串时,查出ID,当作TYPE
endType=eType: 查询下限范围类型ID号或名称(规则同type)
iType=ID1;ID2;...IDn: 文件类型ID列表,形如//错误指示停在此行,提示:Line too long(more than 1023 characters)” name=nName: 指定文件所属用户的ID号或名称
sign=1: 精确匹配type指定的ID号或名称
show=1: 查找最新的资料并直接调用Read.dll?id=[nID] page=N: 按PageRecords分页的页次,当
MaxCount: 设定PageRecords参数,有此参数则page参数无效
ModiCount:
}
QueryReady;
ftype:='';sign:='';name:='';show:='';endType:='';page:='';
listUrl:='';GuidePage:='';ModiCount:='';
ftype:=Request.QueryFields.Values['type'];
endType:=Request.QueryFields.Values['endType'];
sign:=Request.QueryFields.Values['sign'];
name:=Request.QueryFields.Values['name'];
show:=Request.QueryFields.Values['show'];
page:=Request.QueryFields.Values['page'];
MaxCount:=Request.QueryFields.Values['MaxCount'];
ModiCount:=Request.QueryFields.Values['ModiCount']; if (page='') or (ModiCount='1') then page:='1'; //无page参数时置为默认值1
try
if StrToInt(page) <=0 then page:='1';
except
page:='1';
end;
if MaxCount <> '' then begin//设定MaxCount时将page属性置为默认值1
if (not isIntString(MaxCount)) or (StrToInt(MaxCount) <=0) then
MaxCount:=IntToStr(MaxPageRecord);
end else begin
MaxCount:=IntToStr(MaxPageRecord);
end; if (not isIntString(ftype)) and (ftype<>'') then begin //是字符串
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select id from pubItem where type=''文件类型'' and content='''+ftype+'''');
ADOQuery1.Open;
if not ADOQuery1.IsEmpty then begin
ftype:=ADOQuery1.fieldByName('id').AsString
end else begin
try
Response.Content:=PageError.Content;
Exit;
except
response.content:='显示网页时出错!请稍候重试';
QueryFree;
ADOConnection1.Connected:=False;
Handled:=True;
end;
end;
end;
ADOQuery1.Close; if (not isIntString(endType)) and (endtype<>'') then begin //是字符串
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select id from pubItem where type=''文件类型'' and content='''+endType+'''');
ADOQuery2.Open;
if not ADOQuery2.IsEmpty then
endType:=ADOQuery1.fieldByName('id').AsString
else
endType:='';
QueryFree;
end;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT * FROM docList WHERE 1=1 ');
if CompareText(name,'') <> 0 then begin
ADOQuery1.SQL.Add(' AND (name=''' + name + ''' OR usr=''' + name + ''')');
end;
try
if (ftype<>'') and (ftype<>'999999999') then begin
if CompareText(ftype,'0') <> 0 then begin
if sign='1' then begin
ADOQuery1.SQL.Add(' AND typeID=' + ftype);
end else begin
if endType='' then begin
stint:=StrToInt(ftype);
i:=100;
while 1=1 do begin
if (stint mod i) <> 0 then begin
endType:=IntToStr(StrToInt(ftype)+(i div 100));
break;
end else i:=i*100;
end;
end;
ADOQuery1.SQL.Add(' AND typeID >= ' + ftype + ' AND typeID < ' + endType);
end;
end;
end;
except
response.content:='数据库连接错误,请与系统管理员联系。<br>'+ftype;
ADOConnection1.Connected:=False;
Handled:=True;
Exit;
end;
tagStr:=TStringList.Create;
try
try
ADOQuery1.Prepared:=true;
ADOQuery1.Open;
if ADOQuery1.IsEmpty then begin
tagStr.Add('<tr><td align="center"><b><br><br><br>没有更多的资料,谢谢!</b></td></tr>');
end else begin
tagStr.Add('<div align="center"><center><table border=0 width="80%">');
GuidePage:='';
if (CompareText(show,'') <> 0) AND (StrToInt(show) = 1) then
Response.SendRedirect(Request.ScriptName + '/read?id=' + ADOQuery1.FieldByName('ID').AsString);
//定义记录位置与分页
ADOQuery1.First;
j:=ADOQuery1.RecordCount div StrToInt(MaxCount);//求最大页数
if (ADOQuery1.RecordCount mod StrToInt(MaxCount))>0 then j:=j+1;
ListUrl:=Request.ScriptName + '/list?';
if Request.QueryFields.Values['type'] <> '' then
ListUrl:=ListUrl+'type='+Request.QueryFields.Values['type'];
if Request.QueryFields.Values['endType'] <> '' then
ListUrl:=ListUrl+'&endType='+Request.QueryFields.Values['endType'];
if Request.QueryFields.Values['sign'] <> '' then
ListUrl:=ListUrl+'&sign='+Request.QueryFields.Values['sign'];
if Request.QueryFields.Values['name'] <> '' then
ListUrl:=ListUrl+'&name='+Request.QueryFields.Values['name'];
if Request.QueryFields.Values['show'] <> '' then
ListUrl:=ListUrl+'&show='+Request.QueryFields.Values['show'];
if Request.QueryFields.Values['MaxCount'] <> '' then
ListUrl:=ListUrl+'&MaxCount='+Request.QueryFields.Values['MaxCount'];
GuidePage:='';
GuidePage:='<table border="0" cellspacing="0" cellpadding="0"><tr><td nowrap>◎<a href="/" title="返回主页">导航</a>:';
r:=StrToInt(page);
if r>j then r:=j;//r大于最大页数,溢出则回到尾页J
if j>1 then begin
if r=1 then begin
GuidePage:=GuidePage + '<a href="'+
listUrl+'&page='+IntToStr(r+1)+'">下一页</a><font face="Webdings">8</font> ' +
'<a href="'+
listUrl+'&page='+IntToStr(j)+'">尾页</a><font face="Webdings">:</font>';
end else if r=j then begin
GuidePage:=GuidePage + '<font face="Webdings">9</font><a href="'+
listUrl+'&page=1">首页</a> '+
'<font face="Webdings">7</font><a href="'+
listUrl+'&page='+IntToStr(r-1)+'">上一页</a>';
end else begin
GuidePage:=GuidePage + '<font face="Webdings">9</font><a href="'+
listUrl+'&page=1">首页</a> '+
'<font face="Webdings">7</font><a href="'+
listUrl+'&page='+IntToStr(r-1)+'">上一页</a> '+
'<a href="'+
listUrl+'&page='+IntToStr(r+1)+'">下一页</a><font face="Webdings">8</font> ' +
'<a href="'+
listUrl+'&page='+IntToStr(j)+'">尾页</a><font face="Webdings">:</font>';
end;
end;
GuidePage:=GuidePage + '</td><td nowrap> 第</td><td nowrap>'+
'<form name="form1" method="GET" class="bt" action="'+
Request.ScriptName + '/list"><input type="text" size="2" class="bt" name="page" value="'+
IntToStr(r)+'">';
if Request.QueryFields.Values['type'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="type" value="'+Request.QueryFields.Values['type']+'">';
if Request.QueryFields.Values['endType'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="endType" value="'+Request.QueryFields.Values['endType']+'">';
if Request.QueryFields.Values['sign'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="sign" value="'+Request.QueryFields.Values['sign']+'">';
if Request.QueryFields.Values['name'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="name" value="'+Request.QueryFields.Values['name']+'">';
if Request.QueryFields.Values['title'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="title" value="'+Request.QueryFields.Values['title']+'">';
if Request.QueryFields.Values['show'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="type" value="'+Request.QueryFields.Values['show']+'">';
GuidePage:=GuidePage+'</form></td><td nowrap>页</td><td nowrap> [第'+
IntToStr(r)+'页/共'+IntToStr(j)+'页]</td>';
//begin 构造每页示记录数的表单
GuidePage:=GuidePage+'<td nowrap> 每页显示</td><td nowrap align="right"><form name="form2" class="bt" method="GET" action="'+ Request.ScriptName +
'/list"><input type="text" name="MaxCount" class="bt" size="2" value="'+ MaxCount
{IntToStr(PageRecords)}+'">';
if Request.QueryFields.Values['type'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="type" value="'+Request.QueryFields.Values['type']+'">';
if Request.QueryFields.Values['endType'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="endType" value="'+Request.QueryFields.Values['endType']+'">';
if Request.QueryFields.Values['sign'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="sign" value="'+Request.QueryFields.Values['sign']+'">';
if Request.QueryFields.Values['name'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="name" value="'+Request.QueryFields.Values['name']+'">';
if Request.QueryFields.Values['title'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="title" value="'+Request.QueryFields.Values['title']+'">';
if Request.QueryFields.Values['show'] <> '' then
GuidePage:=GuidePage+'<input type="hidden" name="type" value="'+Request.QueryFields.Values['show']+'">';
GuidePage:=GuidePage+'</form></td><td nowrap>条</td></tr></table>'; //end 构造每页示记录数的表单
//定位开始显示的记录
r:=StrToInt(MaxCount) * (StrToInt(page)-1);
ADOQuery1.MoveBy(r);
j:=0;
while (NOT ADOQuery1.Eof) and (j<StrToInt(MaxCount)) do begin
DeCodeDate(ADOQuery1.FieldByName('crtDate').AsDateTime,yy,mm,dd);
tagStr.Add('<tr><td><span style="font-size:5pt">● </span><a href=''' + Request.ScriptName + '/read?id=' + ADOQuery1.FieldByName('ID').AsString + '''>' +
ADOQuery1.FieldByName('title').AsString + ' <i>(' + IntToStr(yy)+'-'+ IntToStr(mm) + '-' + IntToStr(dd) + ')</i></a></td></tr>');
ADOQuery1.Next;
j:=j+1;
end;
tagStr.Add('</table></center></div>');
end;
Response.Content:=PageList.Content;
finally
ftype:='';sign:='';name:='';show:='';endType:='';
page:='';listUrl:='';GuidePage:='';ModiCount:='';
tagStr.Free;
QueryFree;
ADOConnection1.Connected:=False;
Handled:=True;
end;
except
Response.Content:=ErrPage.Content;
end;
QueryFree;
Handled:=true;
end;