You cannot vote in a primary if you are not a member of the party holding the Primary Election.
If you want to change your party affiliation from one party to another, there is a three-month waiting period to attain voting privileges in your new party. In order to vote in the August 14 primary, the deadline to switch from one political party to another is May 14, 2018. The General Statutes of Connecticut, Title 9 - Sec. 9-59 is shown below:
Title 9 - Sec. 9-59. Erasure or transfer of name. Any elector whose name appears on any enrollment list or who has made application for enrollment may, at any time, make a written application, on an application form for admission as an elector, which shall be signed by such elector, to either registrar for erasure of his name from such list or for transfer of his name to the enrollment list of another party. If an elector makes an application for erasure, his name shall be erased from said enrollment list and, if a municipality is having a primary in which unaffiliated electors are authorized to vote, under section 9-431, such elector's name shall be placed on the list of unaffiliated electors together with the date he is eligible to vote in a primary. If an elector makes an application for transfer, his name shall be transferred to the enrollment list of another party, together with the effective date of such transfer. Any elector whose name has been transferred from one enrollment list to another or who has applied for erasure or transfer of his name from an enrollment list shall not be entitled to participate or vote in a caucus or primary of any party, participate in the appointment of members to any board or commission that is political in nature, be appointed as a member of any board or commission that is political in nature or be entitled to the privileges accompanying enrollment in any party for a period of three months from the date of the filing of his application for transfer or for erasure. Any elector who removes his name from the registry list and from an enrollment list in accordance with the provisions of section 9-35b shall not be entitled to enroll in any political party or vote in any primary for three months after such removal. The registrars of voters shall state, on the notice of acceptance sent under sections 9-23g, 9-19b and 9-19e, the date enrollment privileges take effect, if delayed.