I've been creating a class for buttons where you can add and delete rows from the table's database but it is my first time concatenate a string I have a suspicion that it is not working due to commandtext.
 public static void deleteButton(string databaseName, string IDname, DataGridView dgv)
    {
        Helper.openConnection();
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = Helper.cn;
        string IDLocation = dgv.SelectedRows[0].Cells[0].Value.ToString();
        cmd.CommandText = "delete from " + databaseName + " where " + IDname + " = " + IDLocation;
        Helper.cn.Close();
        MessageBox.Show("Successfully Deleted!");
    }
    public static void addButton(string databaseName, List<string> values, DataGridView dgv, bool isAdd)
    {
        Helper.openConnection();
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = Helper.cn;
        string message = isAdd == true? "Sucessfully Added" : "Sucessfully Edited";
        string command = "insert into " + databaseName + " values(";
        for (int i = 0; i < values.Count; i++)
        {
            command += values[i];
            if(i != values.Count - 1) command += ", ";
        }
        command += ")";
        cmd.CommandText = command;
        MessageBox.Show(message);
        Helper.cn.Close();
    }
thank you for your time helping me.
 
     
     
     
    