Representations of surface groups via holomorphic connections EDIT: Tony Pantev has pointed out that the answer to this question will appear in forthcoming work of Bogomolov-Soloviev-Yotov. I look forward to reading it! 
Background
Let $E \to X$ be a holomorphic vector bundle over a complex manifold. A connection $A$ in $E$ is called holomorphic if in local holomorphic trivialisations of $E$, $A$ is given by a holomorphic 1-form with values in End(E).
Notice that the curvature of $A$ is necessarily a (2,0)-form. In particluar, holomorphic connections over Riemann surfaces are flat. This will be important for my question.
The Question
I am interested in the following situation. Let $E \to S$ be a rank 2 holomorphic vector bundle over a Riemann surface of genus $g \geq 2$. I suppose that $E$ admits a global holomorphic trivialisation (which I do not fix) and that we choose a nowhere vanishing section $v$ of $\Lambda^2 E$. (So I do fix a trivialisation of the determinant bundle.) I want to consider holomorphic connections in $E$ which make $v$ parallel. The holonomy of such a connection takes values in $\mathrm{SL}(2,\mathbb{C})$ (modulo conjugation). 
My question: if I allow you to change the complex structure on $S$, which conjugacy classes of representations of $\pi_1(S)$ in $\mathrm{SL}(2,\mathbb C)$ arise as the holonomy of such holomorphic connections?
EDIT: As jvp points out, some reducible representations never arise this way. I actually had in mind irreducible representations, moreover with discrete image in $\mathrm{SL}(2,\mathbb{C})$. Sorry for not mentioning that in the beginning!
Motivation
A naive dimension count shows that in fact the two spaces have the same dimension: 
For the holomorphic connections, if you choose a holomorphic trivialisation of $E\to S$, then the connection is given by a holomorphic 1-form with values in $sl(2, \mathbb C)$. This is a $3g$ dimensional space. Changing the trivialisation corresponds to an action of $\mathrm{SL(2,\mathbb C)}$ and so there are in fact $3g-3$ inequivalent holomorphic connections for a fixed complex structure. Combined with the $3g -3$ dimensional space of complex structures on $S$ we see a moduli space of dimension $6g-6$.
For the representations, the group $\pi_1(S)$ has a standard presentation with $2g$-generators and 1 relation. Hence the space of representations in $\mathrm{SL}(2,\mathbb{C})$ has dimension $6g-3$. Considering representations up to conjugation we subtract another 3 to arrive at the same number $6g-6$.
A curious remark
Notice that if we play this game with another group besides $\mathrm{SL}(2,\mathbb{C})$ which doesn't have dimension 3, then the two moduli spaces do not have the same dimension. So it seems that $\mathrm{SL}(2,\mathbb{C})$ should be important in the answer somehow.
 A: An example
Consider any representation $\varrho$ of $\pi_1(S)$ into $\mathbb C^\ast$.
The representation $\varrho \times \varrho^{-1}$ can be though as representation
on $SL(2,\mathbb C)$. Any connection realizing this representation leave two line
bundles invariant. These lines bundles are determined by the image of 
$\varrho$ and $\varrho^{-1}$ into $H^1(S, {\mathcal O^{\ast}}_S)$ by the natural morphism
$$
Hom(\pi_1(S), \mathbb C^{\ast}) \to H^1(S, \mathbb C^{\ast}) \to H^1(S,{\mathcal O_S}^{\ast})
$$
Thus in this case the representation determines the line-bundle, and it must be of the form $\mathcal L \oplus \mathcal L^*$. Of course the line-bundle $\mathcal L$ may be trivial for some complex structures but not for others. But if we start with a  non-trivial representation with values in $S^1\subset \mathbb C^{\ast}$ then the line-bundle will not be trivial in not matter which complex structure since $H^1(S,S^1)$ is naturally isomorphic to
$\ker H^1(S,\mathcal O_S^{\ast}) \to H^2(S, \mathbb Z)$.
Hilbert's 21st Problem
Your question is related to Hilbert's 21st problem. In it, instead of considering a
compact Riemann surface of genus $g$ with a holomorphic connection on the trivial bundle
one  considers $\mathbb P^1$ minus a finite set $\Gamma$
of points with a meromorphic connection on the trivial bunle with at most simples poles on $\Gamma$. 
It is known that  every representation of $\pi_1(\mathbb P^1 - \Gamma)$ on $SL(2,\mathbb C)$ is realized by a meromorphic connection on the trivial bundle with simple poles on $\Gamma$. I believe that this result
is due to  Birkhoff
In Hilbert's 21st problem a parameter counting does not suffices to exclude the other groups $SL(n,\mathbb C)$, $n \ge 3$. Indeed Bolibruch proved that irreducible representations are always realizable, and constructed counter examples for the general case starting with
dimension $n \ge 3$ if I remember correctly. Moreover, there are examples which show that the answer may depend on the analytic invariants of the set $\Gamma$.
A: Have you compared this to Hitchin's 1987 paper "The Self Duality Equations on a Riemann Surface"? It's like the $SU(2)$ version of your $SL(2,\mathbb{R})$ one.
A: I'm too new to add this to my previous comment so apologies. 
Dmitri, the trivial bundle can be part of a stable Hitchin Pair (specifically if A and B are two matrices without common eigenspaces tensored with independent sections of the canonical bundle). 
The construction above generates maps from the Hitchin moduli space to itself if we start with the flat $SU(2)$ connections and use the Higgs field to define a holomorphic connection and then map the flat connection induced by the holomorphic connection to the one defined by the self-duality equations. Is this not likely to be holomorphic or well behaved under any of the complex structures? 
Likewise for a fixed $SU(2)$ representation there will be a map from the space constructed as suggested above to the Hitchin moduli space for any family of curves (or $SL(2,\mathbb{R})$ representation) and holomorphic connections.
A: This question is addressed in a very recent paper of Bogomolov-Soloviev-Yotov (I don't think it is on the web yet). Among many interesting things they prove that the map from the moduli space of pairs $(C,\nabla)$ where $\nabla$ is a holomorphic connection on the trivial rank two bundle on some smooth curve $C$ is submersive whenever $\nabla$ is irreducible and $C$ is generic. 
With regard to Jack Evans' comment: this is a very different question than the question of determining respresentations in a real form (which has been extensively studied by Hitchin, Goldman, Garcia-Prada, etc.). It is about a holomorphic subvariety in the moduli of representations. A better analogy will be to look at the moduli space of opers which is the moduli space of holomorphic flat connections on a fixed (non-trivial) rank two vector bundle, namely, the 1-st jet bundle of a theta characteristic on the curve.   
