Question: when i clicked on Load\_Table Button, I want to display table from my database in DataGridView, So i wrote that code :

```
private void Load_Table_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection cn = new SqlConnection("Server=ZIKO_RED2486;Database=Students;Integrated Security=true"))
                {
                    if (cn.State == ConnectionState.Open)
                        cn.Close();
                    using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Student", cn))
                    {
                        cn.Open();
                        da.Fill(dt);
                        dataGridView1.DataSource = dt;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

```

* When i clicked the first time it display Student table as expected,
But when clicked the second time The DataGridView display the Student
table twice.
which mean :
[![enter image description here](https://i.stack.imgur.com/ShinJ.png)](https://i.stack.imgur.com/ShinJ.png)
* it looks like the Load\_Table button take the data of Student table
and display it on the content of datagridview.
* i thought of delete the content of datagridview before getting the
data from the table to display it one time. But it still not working.

Help Please.

Answer: 
```
 private void Load_Table_Click(object sender, EventArgs e)
    {
        try
        {
            using (SqlConnection cn = new SqlConnection("Server=ZIKO_RED2486;Database=Students;Integrated Security=true"))
            {
                if (cn.State == ConnectionState.Open)
                    cn.Close();
                using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Student", cn))
                {
                    cn.Open();
                    // we clear 
                    dt.Tables.Clear();
                    // then we fill 
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }

```
just clear your datagrid view

```
this.dataGridView1.Rows.Clear();

```