locked
Query SQL DB data and bind into Gridview RRS feed

  • Question

  • User1864044315 posted

    string machineid = Request["process"];
    
                Label11.Text = machineid;
                //Response.Write(Label11.Text);
                using (SqlConnection con = new SqlConnection(constr))
                {
                    using (SqlCommand cmd = new SqlCommand("SELECT device,Plan_ID,lot_id,qty_in,qty_out,yield,lot_status,datetime FROM Machine_Input WHERE machine_id ='" + Label11.Text + "'", con))
                    {
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            cmd.Connection = con;
                            sda.SelectCommand = cmd;
    
                            using (DataTable dt = new DataTable())
                            {
                                sda.Fill(dt);
                                GridView1.DataSource = dt;
                                GridView1.EmptyDataText = "No Record(s) Found";
                                GridView1.DataBind();

    What is the wrong with above code ?

    The issue is the grid view shows "No Record(s) Found" but there is the data inside the DB.

    Label11.Text are contain with machine id.

    Need you guys help on this.

    Friday, December 16, 2016 6:27 AM

Answers

  • User1864044315 posted

    string machineid = Request["process"];

    problem solve.

    the issue is : silly

    above string have space.

    sorry for disturb you guys.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 16, 2016 7:04 AM