Triazole compounds of the following formulawhere R1, R2, A and B have the meanings given in the description are described. The compounds according to the invention possess a high affinity for the dopamine D3 receptor and can therefore be used for treating diseases which respond to the influence of dopamine D3 ligands.