Intersection Theory on a Surface I have some problems to prove the exercise 20.2.A part (b) in Ravi Vakil's "Fondation of Algebraic Geometry". Here the excerpt:

The setting is: We have a surface $X$ (therefore 2-dimensional, proper $k$-scheme) and two effective divisors $C,D$ (therefore curves) such that $C$ and $D$ don't have common irreducible components.
To show: 
$$(D \cdot C) = h^0(D \cap C, \mathcal{O}_{C \cap D})$$
My efforts: Since by definition and exercise 20.2.A (a) we already know that $(D \cdot C) = deg(\mathcal{O}_X(D) \vert _C) = \chi(\mathcal{O}_X(D) \vert _C) - \chi(\mathcal{O}_C)$
here $\chi$ is the Euler characteristic and $\mathcal{O}_X(D)$ the corresponing invertible sheaf to divisor $D$.
The ideal is to show that following sequence is exact:
(*)$$0 \to \mathcal{O}_C(-D) \to \mathcal{O}_C \to \mathcal{O}_{D \cap C} \to 0$$
and then using the additivity of Euler charecteristic and the fact that $\chi(\mathcal{O}_{C \cap D})= h^0(D \cap C, \mathcal{O}_{C \cap D})$ since this intersection is zero dimensional.
Since this sequence arrises from the sequence $0 \to \mathcal{O}_X(-D) \to \mathcal{O}_X \to \mathcal{O}_D \to 0$ by tensoring with $\mathcal{O}_C$ the only cruical point is to prove that $\mathcal{O}_C(-D) \to \mathcal{O}_C$ is injective. By definition this can be done on level of stalks. 
By definition the stalks are given by $\mathcal{O}_{C,c} = \mathcal{O}_{X,c}/(g)$ and $\mathcal{O}(-D)_{X,c} = f\mathcal{O}_{X,c}$ for regular $f, g \in \mathcal{O}_{X,c}$ since $C,D$ effective divisors.
Therefore we get $\mathcal{O}_C(-D)_c = \mathcal{O}(-D)_{X,c} \otimes \mathcal{O}_{C,c}= f\mathcal{O}_{X,c} \otimes \mathcal{O}_{X,c}/(g) = f\mathcal{O}_{X,c}/(fg)$
So I have to show that $$f\mathcal{O}_{X,c}/(fg) \to \mathcal{O}_{X,c}/(g)$$ is injective for every $c \in C$.
Since $C$ is a curve two cases could happen:


*

*$c$ is generic point (of $C$)

*$c$ is a closed 


Could anybody help to show the desired injectivity for these two cases? I don't see where I can use the assumption that  $C$ and $D$ don't have common irreducible components. Futhermore how to cope with the stalks where $c$ is an embedded component, so $c \in Ass(\mathcal{O}_c)$?
 A: We want to show that if $C,D$ are two curves on a regular surface $X$ such that $C$ does not contain any associated point of $D$, then $\mathcal{O}_C(-D) \rightarrow \mathcal{O}_C$ is injective.  
As you suggested it suffices to check this on stalks. 
Let $A=\mathcal{O}_{X,c}$, and let $f,g \in A$ be local equations for $C,D$ respectively. Then we want to show that the map $A/(f) \rightarrow A/(f)$ given by multiplication by $g$ is injective. It suffices to show that $g\in A/(f)$ is not a zero-divisor.
Suppose otherwise, then there exists $0\ne a\in A/(f)$ such that $ag \in (f)$, i.e. $ag = bf$ in $A$ for some $b\in A$. Let's use the fact that $A$ is a UFD (as it is regular). If $g$ and $f$ do not share any common factors, then $a=0 \in A/(f)$. Therefore we may assume that $g$ and $f$ shares some common factor $h\in A$. 
Now let's lift this result to an open set on $X$. 
By a suitable localisation (i.e. take an affine open containing $c$, and then invert everything that shows up in the denominators in the above), we may assume that $X$ is locally given by $\operatorname{Spec} A'$, $f,g,h \in A'$ and that $g = g'h, f=f'h$ in $A'$ for some $f,f'\in A'$. But this implies that $V(h) \subseteq V(g) \cap V(f)$ in $\operatorname{Spec} A'$. Since $A'$ is an integral domain, $V(h)$ has dimension one. So this implies that $V(g)$ and $V(f)$ share an irreducible component on $\operatorname{Spec} A'$, which implies that they share an irreducible component on $X$. This gives a contradiction.
Note that we actually only used the fact that $C,D$ do not share irreducible components and nothing about embedded points - but as Vakil mentions right after this exercise - in fact $D$ is never going to have embedded points since $X$ is smooth. 
A: I think you want to assume that $S$ is regular, so that $(\mathcal{O}_{X,c})$ is factorial. So we have a factorial ring $R$, and elements $f$, $g$ which cut out $C$, $D$. Since $C$, $D$ do not have common components, we $f$, $g$ are coprime---$\text{gcd}(f,g) = 1$. Now, we want to show that$$f: (gR)/f(gR) = \mathcal{O}_{C,c}(-D) \to \mathcal{O}_{C,c} = R/f\text{ is injective.}$$
To see this, take $g a \in g R$, with $g a = 0$ mod $f$. So $g a = f b$. So $f \mid (g a)$. Since $f$, $g$ are coprime, we have $f \mid a$. Hence $a = c f$, and $g a = g f c$, so $g a \in f g R$.
The best reference for this I know of is Beauville's book Complex Algebraic Surfaces, Chapter 1.
Update: Let's try a second explanation. Concerning your question, you are probably almost there. The issue is that the formula should hold whenever $C$ and $D$ "intersect properly". If say, $X$ is regular, $C$ and $D$ are reduced, this exactly means that $C$ and $D$ have no common irreducible components. In general, we need $C$ and $D$ to be Cartier divisors in $X$, and that $C \cap D$ remains a Cartier divisor in say, $D$. The last condition means that no associated point of $C$ is contained in $D$, or equivalently, that locally $f$ is a nonzero divisor in $\mathcal{O}_{X,c}/(g)$. So multiplication with $f$ is an injective morphism in $\mathcal{O}_{X,c}/(g)$, which looks like what we need.
