locket23
locket23

Reputation: 81

SQL command in C# doesn't work

I have a problem. I'm trying this SqlCommand to get the fields from a Database with 2 conditions :

SqlDataSource1.SelectCommand = "SELECT * FROM Article where Domain like '%Geography%' order by Title";
SqlDataSource1.DataBind();
ListView1.DataBind();

or like :

 SqlDataSource1.SelectCommand = "SELECT * FROM Article where Domain ='Geography' order by Title";
 SqlDataSource1.DataBind();
 ListView1.DataBind();

but the result is I get everything from the Article table meaningless of the Domain name.

My data source is defined as

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="
<%$ ConnectionStrings:WikipediaDatabaseConnectionString %>"
SelectCommand="SELECT * FROM [Article] ORDER BY [Title]"></asp:SqlDataSource>

Upvotes: 0

Views: 158

Answers (1)

Forklift
Forklift

Reputation: 969

If you're running both of those queries, which are as simple as you can make a query and the results are not what you expect, there are only a small number of possibilities:

  • You are not pointing at the database you think you are
  • You are not not actually sending the query you think you are
  • You are not correctly looking at the data and the results are correct

I really don't see how it could be anything but one of these.

Upvotes: 1

Related Questions