First off, like fastcatbestcat said, that loose connector is likely for a non-existent EGR valve that would live down below the intake manifold. If the ECU is designed for an EGR setup then if the connector is off it should throw a 4-1-3 code on socket 6, "EGR temperature signal absent or faulty". Double check to make sure it's not for the knock sensor under the intake manifold, although that should throw a 1-4-3 code on socket 6 if it's disconnected, "Knock sensor signal absent or faulty".
As for your on-going idle and stalling problems, after all you've done I'm suspecting your throttle body may still not be set up quite properly, especially the throttle stop screw, possibly also the TPS even though it's clicking. It's easy to have some little thing slightly out of adjustment that creates idle problems, even intermittent stalling problems. Coincidentally, I learned these lessons the hard way over 30 years ago tinkering with my new '89 740 GLE 16-valve and not knowing enough about what I was doing. If the engine starts idling too low, that's a sign the ECU is not getting the TPS signal or the IAC valve is sticking. If it stumbles and stalls while idling low it can throw the occasional diagnostic code, such as a fuel trim problem or missing rpm signal. These can be red herrings leading you to think the problem is elsewhere when actually it's a side effect of the low idle stumbling and stalling. I once had that happen on a B234F when I was having idle problems. Whenever you get a code, especially in these kinds of circumstances with multiple codes, it's always best to reset the codes and see if the same codes come back before starting to worry about what the code might be telling you.
Going back to basics, I'd double check to make sure your throttle body is correctly adjusted as per the Volvo procedure in TSB 25-202 (link is above). Once everything is guaranteed set up correctly, if you have any further idle/stalling problems then you know it's likely elsewhere, not at the throttle body. I'll summarize the details here from my notes. Please try to follow them step by step to double check the way yours is set up at the moment.
=== Throttle Body Clean, Check & Adjustment - 240/700/900 LH 2.4 B230F/B230FT/B234F - Tips & Techniques ===
1) Make sure the PCV system and throttle body are clean. Remove and clean the flametrap element, check that the small hoses and plastic nipple are clear (the plastic nipples become brittle, be prepared to replace the flametrap if you accidentally break it), remove and check that the brass nipples on the TB are clear as well as the small holes in the throat (use a small drill bit as needed to carefully ream out any grunge being careful not to widen the holes). Make sure the throttle plate is clean, especially the edge, and clean the throat, especially the area around the plate.
2) Check the plate isn't binding. When idling unevenly, too high or even too low, try forcing the throttle closed by hand to see if that makes a difference. Optionally, best to remove it and hold it up to the light, sighting through for an even band of light around the plate to make sure it's centered. Also optionally, with the engine idling, spray carb cleaner or even water around where the throttle shaft comes out of the body; also try it while pulling/pushing on the shaft; if the idle changes then the shaft bushing is worn and letting in unmetered air, so should be repaired/replaced.
3) Readjust the throttle plate stop screw. Loosen the TPS and pop off one end of the linkage rod so they don't affect adjustment. Loosen the stop screw lock nut and back the screw off a turn or so. Now with your fingers holding the throttle plate firmly closed (rotate the TPS if needed), advance the screw until it's touching and you feel the throttle plate is just about to open, then advance the screw 1/4 turn more and secure the lock nut without moving the screw. This keeps the throttle plate partly open when your foot is being taken off and on the gas pedal as the IAC valve takes over.
4) Readjust the TPS. It needs to be adjusted for the click; if set on the hairy edge it can lead to an inconsistent idle and occasional stalls; if overadjusted it can lead to rpm dips and hiccups when taking your foot off and on the gas pedal. Start with the TPS loose and advanced clockwise away from the click. For a Bosch TPS, holding the throttle plate closed, rotate the TPS counter-clockwise past where it clicks until it reaches end of travel then secure in place. For a VDO TPS, insert a 0.25 mm feeler at the stop screw (a strip of heavy bond paper will do) then rotate counter-clockwise until you just hear the click and secure in place. Optionally, you should use the OBD system to verify that the ECU is seeing the TPS closed signal, verifying both the switch and the wiring connections using Diagnostic Test Mode 3 (DTM 3) on socket 2 (refer to the OBD section of the 700/900 FAQ on the UK club website, it's a very easy procedure requiring no tools or even getting your hands dirty).
4a) Another useful thing the OBD system can do is while you have a nostart happening. You can use DTM 3 to verify if the ECU can see the CPS/RPM sensor signal, confirming that both the CPS and wiring connections are okay and not the cause of the no start. Even a relatively new CPS can fail or become intermittent, especially a cheap one and especially one that's subject to abrasion or excessive flexing (the orginal Volvo CPS came with cable standoffs to prevent scuffing and flexing, some aftermarket CPS also come with them). If you're lucky a CPS can last a couple of decades, but I've recently had a supposedly high quality OEM name-brand one fail in less than a year. I always have a known good spare on hand to try swapping and they only take a few minutes to install, especially on the 700/900s as there's more room to work between the engine and firewall than the 240s.
5) Re-connect and check the linkage rod adjustment. The rod should not be adjusted tight, there needs to be a little slack so the TPS can easily click. With the throttle closed there should be a small gap between the throttle spindle (cable pulley) and it's stop on the body. Optionally, you can adjust the linkage rod to spec, inserting a feeler (a strip of heavy bond paper will do) between the trottle spindle and it's stop, adjusting the rod shorter until the TPS no longer clicks, then adjusting it longer until it just clicks with the feeler still inserted. The spec for a 700/900 B230F/B230FT is a 2.5 mm feeler, while the spec for a later B234F is a 1.6 mm feeler, but it doesn't really matter as long as it clicks with a thick piece of paper in the gap.
6) Check throttle cable adjustment (gas pedal cable) so there's a bit of slack in the cable. Some think there should be no slack to maximize WOT air intake, but that's incorrect as the cable needs to expand/contract and flex without affecting the TPS. There's a spec for adjusting the cable measuring freeplay at the pedal.
7) Optionally, if you've got an automatic you can also readjust the trans kickdown cable (refer to the 700/900 FAQ on the UK club website).
================================
Based on my years of owning a B234F, they seemed to need more frequent cleaning of the throttle body, PCV system and spark plugs to keep them idling smooth, especially if you do a lot of city driving as the B234F typically operates at a lower rpm in the city compared to other red block automatics. I found using premium, top-tier gas and an occasional good long highway drive at higher rpms (what people called an Italian tuneup) can really make a difference with these engines.
How do you like the AW72L transmission? It's basically an AW71L transmission used by the B230FT and later B230F, with different gear ratios to better match the skewed torque curve of the B234F 16-valve DOHC. Compared to the AW70/AW71 gearing, I and others found they perhaps went a little too far, making 1st gear a bit too low (more easily spinning wheels on stop lines and wet pavement) with a bit too large a gap between 2nd and 3rd. The lockup feature works well with this powerful engine on the highway allowing you to pass without always kicking down to 3rd.