asp如何读取并显示数据库中超链接文件内容

fengdanyang 2009-08-13 11:10:19
我做了一个上传文件,有好几个类别,存入ACCESS数据库里,上传后显示成功,并点击标题后,显示链接。
问题是,我想同时在另一个页面上根据各个不同类别分别显示前5个,程序有些问题,请帮帮忙,现在把部分程序发给大家!!
<%
''上传文件数据库连接
dim myconn,connstr
connstr = "Provider=Microsoft.Jet.Oledb.4.0;data source="&Server.MapPath("upfile/db1.mdb")
'set myconn = Server.CreateObject("adodb.connection")
'myconn.open connstr
%>
<%
Dim Recordset_up
Dim Recordset_up_numRows

Set Recordset_up = Server.CreateObject("ADODB.Recordset")
Recordset_up.ActiveConnection = connstr
Recordset_up.Source = "SELECT * FROM INFO ORDER BY UploadTime DESC"
Recordset_up.CursorType = 0
Recordset_up.CursorLocation = 2
Recordset_up.LockType = 1
Recordset_up.Open()

Recordset_up_numRows = 0
%>
<%
Dim Recordset_up2
Dim Recordset_up2_numRows

Set Recordset_up2 = Server.CreateObject("ADODB.Recordset")
Recordset_up2.ActiveConnection = connstr
Recordset_up2.Source = "SELECT * FROM INFO WHERE FILETYPE='2'"
Recordset_up2.CursorType = 0
Recordset_up2.CursorLocation = 2
Recordset_up2.LockType = 1
Recordset_up2.Open()

Recordset_up2_numRows = 0
%>
<%
Dim Recordset_up3
Dim Recordset_up3_numRows

Set Recordset_up3 = Server.CreateObject("ADODB.Recordset")
Recordset_up3.ActiveConnection =connstr
Recordset_up3.Source = "SELECT * FROM INFO WHERE FILETYPE='3'"
Recordset_up3.CursorType = 0
Recordset_up3.CursorLocation = 2
Recordset_up3.LockType = 1
Recordset_up3.Open()

Recordset_up3_numRows = 0
%>
<%
Dim Recordset_up4
Dim Recordset_up4_numRows

Set Recordset_up4 = Server.CreateObject("ADODB.Recordset")
Recordset_up4.ActiveConnection = connstr
Recordset_up4.Source = "SELECT * FROM INFO WHERE FILETYPE='4'"
Recordset_up4.CursorType = 0
Recordset_up4.CursorLocation = 2
Recordset_up4.LockType = 1
Recordset_up4.Open()

Recordset_up4_numRows = 0
%>
<%
Dim Recordset_up5
Dim Recordset_up5_numRows

Set Recordset_up5 = Server.CreateObject("ADODB.Recordset")
Recordset_up5.ActiveConnection = connstr
Recordset_up5.Source = "SELECT * FROM INFO WHERE FILETYPE='5'"
Recordset_up5.CursorType = 0
Recordset_up5.CursorLocation = 2
Recordset_up5.LockType = 1
Recordset_up5.Open()

Recordset_up5_numRows = 0
%>
<%
Dim Recordset_up6
Dim Recordset_up6_numRows

Set Recordset_up6 = Server.CreateObject("ADODB.Recordset")
Recordset_up6.ActiveConnection = connstr
Recordset_up6.Source = "SELECT * FROM INFO WHERE FILETYPE='6'"
Recordset_up6.CursorType = 0
Recordset_up6.CursorLocation = 2
Recordset_up6.LockType = 1
Recordset_up6.Open()

Recordset_up6_numRows = 0
%>
<%
Dim Recordset_up7
Dim Recordset_up7_numRows

Set Recordset_up7 = Server.CreateObject("ADODB.Recordset")
Recordset_up7.ActiveConnection = connstr
Recordset_up7.Source = "SELECT * FROM INFO WHERE FILETYPE='7'"
Recordset_up7.CursorType = 0
Recordset_up7.CursorLocation = 2
Recordset_up7.LockType = 1
Recordset_up7.Open()

Recordset_up7_numRows = 0
%>
<%
Dim Repeatup2__numRows
Dim Repeatup2__index

Repeatup2__numRows = 5
Repeatup2__index = 0
Recordset_up2_numRows = Recordset_up2_numRows + Repeatup2__numRows
%>
<%
Dim Repeatup3__numRows
Dim Repeatup3__index

Repeatup3__numRows = 5
Repeatup3__index = 0
Recordset_up3_numRows = Recordset_up3_numRows + Repeatup3__numRows
%>
<%
Dim Repeatup4__numRows
Dim Repeatup4__index

Repeatup4__numRows = 5
Repeatup4__index = 0
Recordset_up4_numRows = Recordset_up4_numRows + Repeatup4__numRows
%>
<%
Dim Repeatup5__numRows
Dim Repeatup5__index

Repeatup5__numRows = 5
Repeatup5__index = 0
Recordset_up5_numRows = Recordset_up5_numRows + Repeatup5__numRows
%>
<%
Dim Repeatup6__numRows
Dim Repeatup6__index

Repeatup6__numRows = 5
Repeatup6__index = 0
Recordset_up6_numRows = Recordset_up6_numRows + Repeatup6__numRows
%>
<%
Dim Repeatup7__numRows
Dim Repeatup7__index

Repeatup7__numRows = 5
Repeatup7__index = 0
Recordset_up7_numRows = Recordset_up7_numRows + Repeatup7__numRows
%>
<%
Dim UP_paramName
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim UP_keepNone
Dim UP_keepURL
Dim UP_keepForm
Dim UP_keepBoth

Dim UP_removeList
Dim UP_item
Dim UP_nextItem

' create the list of parameters which should not be maintained
UP_removeList = "&index="
If (UP_paramName <> "") Then
UP_removeList = UP_removeList & "&" & UP_paramName & "="
End If

UP_keepURL=""
UP_keepForm=""
UP_keepBoth=""
UP_keepNone=""

' add the URL parameters to the UP_keepURL string
For Each UP_item In Request.QueryString
UP_nextItem = "&" & UP_item & "="
If (InStr(1,UP_removeList,UP_nextItem,1) = 0) Then
UP_keepURL = UP_keepURL & UP_nextItem & Server.URLencode(Request.QueryString(UP_item))
End If
Next

' add the Form variables to the UP_keepForm string
For Each UP_item In Request.Form
UP_nextItem = "&" & UP_item & "="
If (InStr(1,UP_removeList,UP_nextItem,1) = 0) Then
UP_keepForm = UP_keepForm & UP_nextItem & Server.URLencode(Request.Form(UP_item))
End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
UP_keepBoth = UP_keepURL & UP_keepForm
If (UP_keepBoth <> "") Then
UP_keepBoth = Right(UP_keepBoth, Len(UP_keepBoth) - 1)
End If
If (UP_keepURL <> "") Then
UP_keepURL = Right(UP_keepURL, Len(UP_keepURL) - 1)
End If
If (UP_keepForm <> "") Then
UP_keepForm = Right(UP_keepForm, Len(UP_keepForm) - 1)
End If

' a utility function used for adding additional parameters to these strings
Function UP_joinChar(firstItem)
If (firstItem <> "") Then
UP_joinChar = "&"
Else
UP_joinChar = ""
End If
End Function
%>
这些是数据库部分,下面将是显示链接 部分

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="6%" height="30" rowspan="2"><img src="images/sub.gif" width="31" height="30"></td>
<td width="76%" height="28"> <strong>国际新闻</strong></td>
<td width="18%" align="center"> </td>
</tr>
<tr>
<td height="2" colspan="2" bgcolor="#6699cc"> </td>
</tr>
<tr>
<td colspan="3"><%
While ((Repeatup2__numRows <> 0) AND (NOT Recordset_up2.EOF))
%>



<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5" colspan="2"></td>
</tr>
<tr>
<td width="6%"><img src="images/point.jpg" width="11" height="11" align="right"></td>
<td width="94%" colspan="2">
<A HREF="<%=FILEPATH%>?<%= Server.HTMLEncode(UP_keepNone) & UP_joinChar(UP_keepNone) & "ID=" & Recordset_up2.Fields.Item("ID").Value %>"><%=(Recordset_up2.Fields.Item("FILETITLE").Value)%></A></td>

</tr>
</table>
<%
Repeatup2__index=Repeatup2__index+1
Repeatup2__numRows=Repeatup2__numRows-1
Recordset_up2.MoveNext()
Wend
%>
</td>
</tr>
</table>
现在网页上能显示标题,但是点击后不显示,网址变成http://localhost/ID=2,好像根本就没读<%=FILEPATH%>
谢谢大家了!
...全文
70 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
phoeni_xin 2009-08-13
FILEPATH 没读取。

回复
fengdanyang 2009-08-13
我知道没读取,可是怎么做才能读取呢?
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告