查询返回任何记录显示在我的网页 [英] Query returns no records to show on my webpage

查看:265
本文介绍了查询返回任何记录显示在我的网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在那里我运行下面的code网站:

 < ASP:的AccessDataSource ID =AccessDataSource1=服务器
    数据文件=〜/ App_Data文件/ TravelJoansDB.accdb
    的SelectCommand =SELECT * FROM [表2] INNER JOIN BlogEntryItems ON Table2.ID = BlogEntryItems.BlogID WHERE([Table2.ID] = @ ID)>
    < SelectParameters>
        < ASP:QueryStringParameter名称=IDQueryStringField =Table2.IDTYPE =十进制/>
    < / SelectParameters>
< / ASP:的AccessDataSource>
 

这似乎返回任何记录,虽然我已经运行在Access查询,并返回我期待的记录。注:在我的访问查询,我取代

  WHERE([Table2.ID] = @ ID)
 

 ,其中Table2.ID = 4
 

解决方案

请在你的code中的查询完全一样,你正在运行对访问之一。 (替换 @ID 4 )。 如果它返回你所期望的记录,问题是与 @ID

如果它仍然显得返回任何记录,那么你的问题是,无论是与你是如何将您的命令将数据库或如何你正在阅读的结果。

I've got a website where I'm running the following code:

<asp:AccessDataSource ID="AccessDataSource1" runat="server"
    DataFile="~/App_Data/TravelJoansDB.accdb"
    SelectCommand="SELECT * FROM [Table2] INNER JOIN BlogEntryItems ON  Table2.ID=BlogEntryItems.BlogID WHERE ([Table2.ID]=@ID)">
    <SelectParameters>
        <asp:QueryStringParameter Name="ID" QueryStringField="Table2.ID" Type="Decimal" />                    
    </SelectParameters>
</asp:AccessDataSource>

It seems to return no records, although I have run the query in Access and it returns the records I'm expecting. Note: In my query in Access, I substituted

WHERE ([Table2.ID]=@ID)

with

WHERE Table2.ID=4

解决方案

Make the query in your code exactly the same as the one you're running against Access. (Replace @ID with 4.) If it returns the records you expect, the problem is with @ID.

If it still appears to return no records, then your problem is either with how you're sending your command to the database or how you're reading the results.

这篇关于查询返回任何记录显示在我的网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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