<p>I have a table in a MySql database that stores user accounts. One of the columns, expires, stores an expiration date but defaults to NULL. I need to be able to remove an expiration date and set it back to the default value.</p>

<p>Currently, all of my CRUD routines are written using MySqlCommand with parameters. Can this be done directly with a MySqlParameter, or do I have to create an alternate command object to handle this eventuality?</p>

[{'answer_id': 51257, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 0, 'selected': False, 'text': '<p>It\'s not clear what conditions you\'re talking about. If you want to set column to default value, you can use <a href="http://msdn.microsoft.com/en-us/library/system.dbnull.value.aspx" rel="nofollow noreferrer">DbNull.Value</a>;</p>\n\n<pre><code>command.AddWithValue("@param", DbNull.Value);\n\nor\n\ncommand.Parameters.Add("@param", &lt;data type&gt;).Value = DBNull.Value;\n</code></pre>\n'}, {'answer_id': 58277, 'author': 'Adam Lassek', 'author_id': 1249, 'author_profile': 'https://Stackoverflow.com/users/1249', 'pm_score': 3, 'selected': True, 'text': '<p>The problem was DBNull, doing:</p>\n\n<pre><code>command.Parameters.AddWithValue("@parameter", null);\n</code></pre>\n\n<p>compiles OK.</p>\n'}, {'answer_id': 4249329, 'author': 'JYelton', 'author_id': 161052, 'author_profile': 'https://Stackoverflow.com/users/161052', 'pm_score': 0, 'selected': False, 'text': '<p>I usually set values that are intended to be default/blank to null in code, then before executing the query, run the following loop:</p>\n\n<pre><code>foreach(MySqlParameter param in cmd.Parameters)\n    if (param.Value == null) param.Value = DBNull.Value;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/51238', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1249/']