0

Hi I have the following coding whereby I am trying to show Properties that have their price within the from and to drop down menus. However it only works well when the from price is set to 0. when I do price from 1000 to 800000, properties within that range are not shown.

SqlConnection con = new SqlConnection(connString);
        con.Open();
        string sql = "SELECT RefNo, Price, Location, Type, Image_Path1 FROM Properties WHERE  Basis = '" + basis.SelectedItem + "'and Location = '" + location.SelectedItem + "'  and Type = '" + type.SelectedItem + "' and Price > '" + from.SelectedItem + "' and Price < '" + to.SelectedItem + "' ";
        SqlCommand cmd = new SqlCommand(sql, con);

        try
        {
            datalist1.DataSource = cmd.ExecuteReader();
            datalist1.DataBind();
            cmd.Connection.Dispose();
            con.Close();
        }

Edited by __avd: Added [code] tags.

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Sergey.Smirnov
0

What type is Price and what values do you have in from.SelectedItem/to.SelectedItem? I'd take a look at what the sql variable looks like before you call ExecuteReader().

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.