查询似乎不返回行,但它确实访问 [英] Query seems to return no rows, but it does in Access

查看:106
本文介绍了查询似乎不返回行,但它确实访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的查询字符串参数返回,然后在下面的code使用的值:

I use a querystring parameter to return a value that is then used in the code below:

<asp:AccessDataSource ID="AccessDataSource2" runat="server" 
    DataFile="~/App_Data/TravelJoansDB.accdb" 
    SelectCommand="SELECT * FROM [PeoplePhotos] WHERE ID = @ID">
    <SelectParameters>
        <asp:QueryStringParameter Name="ID" QueryStringField="ID" />                    
    </SelectParameters>
    </asp:AccessDataSource>
    <table class="picPageStyle">
        <tr>
            <td>
                <asp:Image ID="Image1" runat="server" BorderWidth="1px" ImageUrl='<%# "PlaceImages/" + Eval("picPath") %>' />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("picDesc") %>' />
            </td>
        </tr>
    </table>

查询很容易返回一行时,我代替在访问@ID的值,似乎(但似乎我错了),因为页面的地址,使用这个,它是返回值code显示了正确的ID,即picpage.aspx?ID = 4我在想什么?它说的是与查询参数?

The query would easily return a row when I substitute a value for "@ID" in Access and it seems (but it seems that I'm wrong) that it is returning the value because the address of the page that uses this code shows the right ID, i.e. "picpage.aspx?ID=4" What am I missing? Is it something with the querystring parameter?

推荐答案

您必须到位表到一个FormView:

You must be place Table into a FormView:

<asp:FormView ID="FormView1" runat="server" DataSourceID="AccessDataSource2">
    <ItemTemplate>
       <table class="picPageStyle">
         <tr>
           <td>
              <asp:Image ID="Image1" runat="server" BorderWidth="1px" ImageUrl='<%# "PlaceImages/" + Eval("picPath") %>' />
           </td>
         </tr>
         <tr>
            <td>
               <asp:Label ID="Label1" runat="server" Text='<%# Eval("picDesc") %>' />
            </td>
         </tr>
     </table>
    </ItemTemplate>
</asp:FormView>

这篇关于查询似乎不返回行,但它确实访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆