Topological electronic materials have become a prominent research frontier in condensed matter physics. Using first-principles calculations, we study the topological electronic properties of the ternary boride \mathrmW_2 \mathrmCoB_2. After detailed Hubbard U calculation tests, we select the non-magnetic state as the ground state of the system. Firstly, we calculate the band structures of this material. When the spin-orbit coupling (SOC) is ignored, several nodal lines appear in the first Brillouin zone of \mathrmW_2 \mathrmCoB_2, and the material shows the topological nodal line semimetal phase. These nodal lines are protected by the mirror symmetry or the combined space-inversion and time-reversal symmetry. Some nodal lines form closed nodal rings, which intersect with the endless nodal lines extending throughout the whole Brillouin zone, forming nodal chains. All of the nodal lines are gapped when SOC is included, and the system transits into a strong topological insulator with Z_2 invariant of (1 ; 000). An odd number of gapless surface Dirac cones appear on the both (\overline1 10) and (001) surfaces, with the two branches connecting the valence and conduction bands respectively, confirming the nontrivial topological properties of \mathrmW_2 \mathrmCoB_2. The cleavage energies of these two surfaces are approximately 7.08 \mathrm~J \cdot \mathrm~m^-2, indicating their potential for experimental cleavage. The topological phase of this material remains stable under strain. After applying -5 \% to 5 \% equiaxial strain, the shape and number of nodal lines are not affected, and the system still shows the topological nodal line semimetal phase in the absence of SOC. When SOC is considered, the system remains the strong topological insulator phase. Specifically, the band gap at the Dirac point along the \Gamma \rightarrow X direction first decreases and then increases with the increase of strain. It decreases to a minimum value of 0.63 meV under the strain of -2.2 \% and then reaches the maximum value of 15 meV when the strain increases to 5 \%. The band gap variation is attributed to the hybridization between the \mathrmW-d_x^2-y^2 and \mathrmCo-d_y z orbitals. This hybridization initially weakens as the strain increases from -5 \% to -2.2 \%, but then becomes stronger as the strain is further increased. Furthermore, when the uniaxial strain along z-axis ranging from 5 \% to -3.99 \% is applied, the band gap at the X point gradually decreases, and the system remains the strong topological insulator phase. When the uniaxial strain reaches -3.99 \%, the band gap at the X point closes, indicating the topological phase transition critical point. With the further decrease of strain, this band gap opens again, and the system transitions into a weak topological insulator. This study systematically reveals the robust nontrivial topological electronic properties in the ternary boride \mathrmW_2 \mathrmCoB_2, laying the foundation for the research on topological nodal line semimetal and the design of low-dissipation spintronic devices.