title: Unable to remove unnecessary whitespace before Textbox submission to Database C#
body: <p>I have been trying to remove duplicate whitespace from textbox before the data is submitted to database. I have tried <code>TRIM()</code> function in MySQL, like </p>
  
  <pre><code>cmd.CommandText = "INSERT INTO table1 VALUES TRIM(('" + textBox1.Text + "', '" + textBox2.Text + "'))";
  </code></pre>
  
  <p>it did not work. I also tried this</p>
  
  <pre><code>textBox1.Text = textBox1.Text.Replace("  ", " ");
  </code></pre>
  
  <p>I added above code to the submission button which works but it only removes whitespace if it appears twice, as in, double space. In a case where the user input more than two spaces, how do I implement it?</p>
  
  <p>For example: <code>"Hello    World"</code> should be submitted as <code>"Hello World"</code></p>