hi i tried to search from a dataset but when i try to add from a dataset to a datagridview it is not adding to the datagridview. here is my code. moreover if i try a messagebox the result found is being displayed.

con.Open();
            cmd = new SqlCommand("sp_getUsersDetails", con);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@Username", SqlDbType.VarChar);
            cmd.Parameters["@Username"].Value = txtSearch.Text;
            cmd.Parameters["@Username"].Direction = ParameterDirection.Input;

            
            SqlDataReader rdr = cmd.ExecuteReader();
            

            while (rdr.Read())
            {
                dgvUsers.DataSource = ds.Tables["tblUser"].Rows.Add(rdr[0].ToString());
                dgvUsers.Update();
            }
cmd = new SqlCommand("sp_getUsersDetails", con);
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("@Username", SqlDbType.VarChar);
cmd.Parameters["@Username"].Value = txtSearch.Text;
cmd.Parameters["@Username"].Direction = ParameterDirection.Input;

SqlDataAdapter adp=new SqlDataAdapter(cmd);
DataTable dt=new DataTable();
adp.Fill(dt);

dgvUsers.DataSource=dt;

solved thanks

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.