Q:

The variable name '@product_Id' has already been declared.  Variable names must be unique within a query batch or stored procedure

i insert the data from datagridview to database table.  but the error that come in the exception i write in the title.  the value save in the database table as well. 
private void btnSavePurchases_Click(object sender, EventArgs e)
{
    if ((string. IsNullOrEmpty(txtPGrandTotal. Text)) || (txtPGrandTotal. Text == "0")) 
    {
        MessageBox. Show("No record available");
    }
    else
    { 
        try
        {           
            string query1 = "INSERT INTO purchases (productId) values (@product_Id)";
            command = DBConnectivity.getCommandForQuery(query1, connection);
            for (int i = 0; i < dGvPurchases. Rows. Count; i++)
            {
                //   command. Parameters. Clear();
                command. Parameters. AddWithValue("product_Id", dGvPurchases. Rows[i].Cells[9].Value);
                command. ExecuteNonQuery();
            }            
        }
        catch (Exception ex)
        {
        }
    }
}

A:

Probably
AddWithValue("product_Id"...

should be
AddWithValue("@product_Id"...

By the way, since you add your parameters in a for loop, you need clear them top of your for loop.  That's why you need to uncomment your command. Parameters. Clear() part.  Without Clear method, you try to add same parameter name over and over again to same command and you will get an error in your second iteration. 
As an another solution, you can declare your parameter name outside of your loop and add it's value inside of loop. 
And don't use AddWithValue as much as possible.  It may generate unexpected results sometimes.  Use .Add() overloads to specify your db type and it's size.  
Don't forget to use using statement as well to dispose your command object.