我正在尝试创建一个转发器控件,但我遇到了一个小问题。以下是转发器控制代码:
<asp:Repeater ID="movies" runat="server">
<ItemTemplate>
<table>
<tr>
<th>
Movie Title: <%# Container.DataItem("MovieTitle")%>
</th>
<th>
Genre: <%# Container.DataItem("Genre")%>
</th>
</tr>
<tr>
<td>
<%# Container.DataItem("Synopsis")%>
</td>
</tr>
<tr>
<td>
Staring: <%# Container.DataItem("Starring")%>
</td>
</tr>
<tr>
<td>
Director: <%# Container.DataItem("Director")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
控件的VB代码背后是:
movie_title = Request.QueryString("id")
myConn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = " & _
Server.MapPath("../App_Data/MovieBoard.accdb"))
myConn.Open()
Dim sqlQuery = "Select movieID From Movies"
Dim aCmd = New OleDbCommand(sqlQuery, myConn)
aDataReader = aCmd.ExecuteReader()
If aDataReader.Read() = True Then
movieID = aDataReader(0)
Else
movieID = "0"
End If
query = ("Select MovieTitle, Genre, Synopsis, Starring, Director From Movies")
cmd = New OleDbCommand(query, myConn)
dr = cmd.ExecuteReader()
movies.DataSource = dr
movies.DataBind()
然而,当我运行代码时,我得到了一个:
Cannot use a leading .. to exit above the top directory.
Line 12: Dim query, movie_title, movieID As String
Line 13: movie_title = Request.QueryString("id")
Line 14: myConn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = " & _
Line 15: Server.MapPath("../App_Data/MovieBoard.accdb"))
Line 16: myConn.Open()
我认为问题很小但我似乎无法找到问题。
答案 0 :(得分:2)
看起来像您正在使用的Server.MapPath。尝试:
Server.MapPath("/App_Data/MovieBoard.accdb")
../要求文件夹升级一级,错误告诉你它不能更高。