Connection on line bundle on projective curve Let $C$ be a smooth projective curve. It is known that a line bundle on $C$ is of degree 0, if we can impose a connection structure on it.
Now my question is:
Given a line bundle $L$ of degree 0, if there exist connection structure on $L$.
When $C$ is projective line, the question is obvious, how about when the genus is greater than 0?
 A: Yes (we're over C yes?)- the space of line bundles with connection forms a torsor for the cotangent bundle over the Jacobian. The class of this torsor (as an element in $H^1(Jac,\Omega^1)=H^{1,1}$) is the Chern class of the theta line bundle. In fact one can construct canonical connections on generic line bundles of degree zero on a curve (in fact line bundles outside the theta divisor), once you give yourself the choice of a theta characteristic on the curve -- this is the theory of the "prime form" or Szego kernel (it's much much older, but I think a fairly easy "modern" exposition of this and the nonabelian version is in here).
[EDIT: Nonalgebraically it is very easy to see this assertion from the Hodge theorem: the space of line bundles with a flat connection is $H^1(X,C^\times)$, which can be identified with the product $H^1(X,O^\times)^{\circ}\times H^0(X,\Omega^1)$ just by exponentiating the Hodge theorem for H^1. Note that ANY holomorphic connection on a Riemann surface/algebraic curve is flat for dimension reason - there are no holomorphic 2-forms that could serve as curvature.. For higher rank bundles the analogous result is the topic of the Corlette-Simpson nonabelian Hodge theorem.]
More generally Andre Weil proved that a rank n bundle on a curve /C admits a connection if and only if every indecomposable summand is a vector bundle of degree zero. There's a nice proof of this by Atiyah as an application of the Atiyah class  (which is the canonical obstruction to the existence of a connection on a vector bundle). In particular over the moduli of stable degree zero bundles we again have a nontrivial torsor for the cotangent bundle parametrizing bundles with connection, and the class of this torsor is again the Chern class of the determinant line bundle.
A: I also wanted to add a more elementary algebraic way of looking at this (compared to David's answer). Namely, let's write your line bundle as a divisor, so $L\simeq O(D)$. Outside of the support of $D$, $L$ is trivial, and so a connection on $L$ is the same as a connection on $O$, that is, a differential $1$-form $\omega$. But this holds only outside of the support of $D$: $\omega$ can have poles along $supp(D)$. A local calculation shows that for $\omega$ to  give a regular connection on $L$, $\omega$ must have first-order poles at $x_i$ with residue $-k_i$, where $D=\sum k_ix_i$. So now the claim is reduced to the classical statement: a rational differential form with prescribed residues exists iff the sum of residues is zero. (Which may be viewed as an explicit calculation of $H^1(C,\Omega_C)$.) 
A: Yes, you can: Every holomorphic line bundle of degree $0$ has a flat connection which is compatible with the holomorphic structure, i.e. $\nabla s=w_s s$ for local holomorphic sections, where $w_s\in\Gamma(M,K).$ But flatness implies $d w_s=0.$ Thus $\nabla$ is a holomorphic connection. 
To see the existence of a flat connection compatible with the holomorphic structure, take any connection $\tilde\nabla$ compatible with the holomorphic structure. The curvature $F$ satisfies $\int_MF=0,$ so Serre duality implies the existence of a section $\eta\in\Gamma(M;K)$ with $d\eta=F.$ Then $\nabla=\tilde\nabla-\eta$ is flat and also compatible with the holomorphic structure.  
