public partial class Default7 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         string selectSQL;
        selectSQL = "SELECT Ref#,Description,Quantity,Warning_Quantity FROM Products ";

        SqlConnection con = new SqlConnection();

        con.ConnectionString = "Data Source=.;Initial Catalog=Project;User ID=sa;Password=786";
        SqlCommand cmd = new SqlCommand(selectSQL, con);
        SqlDataReader reader;
        // SqlDataReader reader1;

        // Try to open database and read information.
        try
        {
            con.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                int q = Convert.ToInt32(reader["Quantity"].ToString());
                int wq = Convert.ToInt32(reader["Warning_Quantity"].ToString());
                if (q==wq)
                {
                    Label label124 = new Label();
                    label124.Text = reader["Ref#"].ToString();
                    PlaceHolder3.Controls.Add(label124);
                 //   PlaceHolder3.Controls.Add(new LiteralControl("<br/>"));


                    Label label123 = new Label();
                    label123.Text = reader["Description"].ToString();
                    PlaceHolder2.Controls.Add(label123);
                  //  PlaceHolder2.Controls.Add(new LiteralControl("<br/>"));

                    Label label = new Label();
                    label.Text =wq.ToString();
                    PlaceHolder1.Controls.Add(label);
                    //PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));








                }
                //PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));


            }
          //  labellll.Text = "REcord Inserted";
            reader.Close();




        }
        catch (Exception err)
        {
            //lblStatus.Text = "Error in displaying data. ";
            //lblStatus.Text += err.Message;
        }
        finally
        {
            con.Close();
        }
    }

Specify your problem please?

It seems as if you had a statement in SQL with the following where clause, you could save a lot of code instead of looping and comparing values outside of the SQL:

" WHERE Quantity=Warning_Quantity"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.