title: Insert null value in database
body: <p>I have a database in MySQL Workbench with fields like (name, lastname, age, address, etc..) and a windows desktop application (a form) in visual studio with c# where you can insert, search and update.
  When I insert data from the form and I leave some fields empty, they are saved in the database as blank and I want them to be saved as null.
  Is there a way to make that happen?</p>
  
  <p>Here is and insert button code:</p>
  
  <pre><code>conn = openconnection.GetConn();
  
  MySqlCommand cmd = new MySqlCommand("INSERT INTO table_name (name,lastname,address, etc...) VALUES (' " + name_textbox.Text + " ',' " + lastname_textbox.Text + " ' etc... );", conn);
  
  cmd.CommandType = CommandType.Text;
  cmd.ExecuteNonQuery();
  conn.Close();
  </code></pre>
  
  <p>Thanks a lot, it works fine but I have a problem with words with spaces, like: (father name , mother name , etc). When I insert a value at name it is fine but when I insert a value at father name or mother name it is null. I think it is because of space between words.</p>
  
  <pre><code>MySqlCommand cmd = new MySqlCommand("INSERT INTO table_name (name,`father name`,`mother name`, etc... VALUES (@name,@`father name`,@`mother name`,etc...);", conn);
  
  cmd.Parameters.AddWithValue("@name", name_textbox.Text.NullString());
  cmd.Parameters.AddWithValue("@`father name`", father_name_textbox.Text.NullString());
  cmd.Parameters.AddWithValue("@`mother name`", mother_name_textbox.Text.NullString());
  
  cmd.ExecuteNonQuery();
  </code></pre>