0

我正在尝试创建一个中继器控件,但遇到了一个小问题。以下是中继器控制代码:

<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()

我认为问题很小,但我似乎无法找到问题所在。

4

1 回答 1

2

看起来像您正在使用的 Server.MapPath。尝试:

Server.MapPath("/App_Data/MovieBoard.accdb")

../ 要求上一层的文件夹,错误告诉你它不能再高了。

于 2012-12-21T00:19:52.047 回答