[英]SQL command in C# doesn't work
我有個問題。 我正在嘗試使用此SqlCommand從具有2個條件的數據庫中獲取字段:
SqlDataSource1.SelectCommand = "SELECT * FROM Article where Domain like '%Geography%' order by Title";
SqlDataSource1.DataBind();
ListView1.DataBind();
或喜歡:
SqlDataSource1.SelectCommand = "SELECT * FROM Article where Domain ='Geography' order by Title";
SqlDataSource1.DataBind();
ListView1.DataBind();
但是結果是我從Article表中獲得了所有與域名無關的信息。
我的數據源定義為
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="
<%$ ConnectionStrings:WikipediaDatabaseConnectionString %>"
SelectCommand="SELECT * FROM [Article] ORDER BY [Title]"></asp:SqlDataSource>
如果您同時運行這兩個查詢,因為它們非常簡單,但查詢結果卻並非您期望的那樣,只有少數可能性:
除了其中之一,我真的看不到任何東西。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.