0
我遇到問題。 我想這樣的SqlCommand獲得從數據庫中的字段有2個條件:C#中的SQL命令不起作用
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();
但結果卻是我從文章表無意義域得到一切名稱。
我的數據源定義爲
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="
<%$ ConnectionStrings:WikipediaDatabaseConnectionString %>"
SelectCommand="SELECT * FROM [Article] ORDER BY [Title]"></asp:SqlDataSource>
如何連接ListView1和SqlDataSource1? – Andrei
你可以發佈你的整個連接代碼嗎 –
如果你直接在SQL中運行它(例如通過SSMS),它會工作嗎?看起來這個查詢沒有問題。顯示你的listview和Sql數據源是如何鏈接的。目前尚不清楚一個人是否對另一個人有影響。 – ADyson