[Solved] How to stop duplicating the data in database everytime the form loads?


I don’t understand the need of your “reports” table,… If I was you I’ll use only ShowData() with the query, like this

public void ShowData()
    {
        con = new SqlConnection(@"Data Source=LAPTOP-KA7UGSG3;Initial Catalog=JAPoultry;Integrated Security=True");
        con.Open();
        da = new SqlDataAdapter("SELECT Variety, SUM(Quantity) FROM Inventory GROUP BY Variety", con);
        dt = new DataTable();
        da.Fill(dt);
        dgv_Reports.DataSource = dt;
    }
    private void frmReports_Load(object sender, EventArgs e)
    {
        ShowData();
    }

4

solved How to stop duplicating the data in database everytime the form loads?