getting error while replacing the single quotes from text
<p>I have a text box with tinyMCE editor, i am giving some text from that text box with single quotes, but in query it is showing syntax error</p>

<p>I am trying to remove the single quotes by this </p>

<pre><code>txbCaption.Text = txbCaption.Text.Replace("'", "''");
</code></pre>

<p>and my query</p>

<pre><code>public void UpdateCaptions(Hashtable hashtable)
        {
            if (hashtable != null)
            {
                foreach (int key in hashtable.Keys)
                {
                    string query = "update Image set Description='" + hashtable[key] + "' where Id=" + key;
                    // in this query i am getting error
                    SqlHelper.ExecuteNonQuery(Conn, CommandType.Text, query);
                }
            }
       }
</code></pre>

<p>first i am calling replace Text.Replace("'", "''");<br>
after that i am assigning this to </p>

<pre><code>if (ViewState["imgIdCapHtbl"] != null)
     imgIdCapHtbl = (Hashtable)ViewState["imgIdCapHtbl"];
int index = Convert.ToInt32(ViewState["pSelecectedImgIndex"]);

if (imgIdCapHtbl != null &amp;&amp; imgIdCapHtbl.ContainsKey(imgIds[index]))
         imgIdCapHtbl[imgIds[index]] = txbCaption.Text;
</code></pre>

<p>and imgIdCapHtbl hashtable key i am sending to query for saving discription</p>

<p>when i am giving the single quotes in my text then in query 2 times single quotes is getting added.</p>

<p>I used regular exp. validation also but because of TinyMCE editor its not working for that.</p>

<p>some one plz tell me how to replace single quotes, I want if user wants to give single to with text then text box should accept the single quotes and my data gets save without any error, </p>
