title: how to prepare a string to be inserted into MySQL e.g. add backslash
body: <p>I have a description of a thing that need to be inserted into MySQL. A string can have any character like &lt;'>, &lt;\'>,&lt;\'>:</p>
  
  <pre><code>    string=This \'is\' a string
      string=This is a' string
      string=This '\is\' a string
  </code></pre>
  
  <p>C# code:</p>
  
  <pre><code>   strDescerption=strDescerption.Trim(new char[] { '\'', '\\' }).Replace("'''", " ").Replace("''", "\"").Replace("'", @"\'").Replace(@"\\'", @"\'");
  
              MySqlCommand mySqlCommandThing = new MySqlCommand("", mySqlConnection);
              mySqlCommandThing.CommandText = "Insert into table (string) values ("+ strDescerption+")";
              int isInserted = mySqlCommandThing.ExecuteNonQuery();
  </code></pre>
  
  <p>If I use them like that I will get MySQL insert error. 
  The above examples are the original string, and just adding backslash before ' cant solve the problem. What else can I do in order to preparing this string? I am using C# and MySQL.</p>