<p>I've got a DataSet in VisualStudio 2005.  I need to change the datatype of a column in one of the datatables from <code>System.Int32</code> to <code>System.Decimal</code>.  When I try to change the datatype in the <code>DataSet Designer</code> I receive the following error:</p>

<blockquote>
  <p>Property value is not valid.  Cannot change DataType of a column once
  it has data.</p>
</blockquote>

<p>From my understanding, this should be changing the datatype in the schema for the DataSet.  I don't see how there can be any data to cause this error.</p>

<p>Does any one have any ideas?</p>

[{'answer_id': 47298, 'author': 'Codeslayer', 'author_id': 4021, 'author_profile': 'https://Stackoverflow.com/users/4021', 'pm_score': 3, 'selected': False, 'text': "<p>Since filled Datatables do not entertain a change in the schema a workaround can be applied as follows:</p>\n\n<ol>\n<li><p>Make a new datatable</p></li>\n<li><p>Use datatable's Clone method to\n    create the datatable with the same\n    structure and make changes to that\n    column</p></li>\n<li><p>In the end use datatable's ImportRow\n    method to populate it with data.</p></li>\n</ol>\n\n<p>HTH</p>\n"}, {'answer_id': 47303, 'author': 'firedfly', 'author_id': 3123, 'author_profile': 'https://Stackoverflow.com/users/3123', 'pm_score': 2, 'selected': False, 'text': '<p>I have found a work around.  If I delete the data column and add it back with the different data type, then it will work.</p>\n'}, {'answer_id': 1905709, 'author': 'Are', 'author_id': 231880, 'author_profile': 'https://Stackoverflow.com/users/231880', 'pm_score': 6, 'selected': True, 'text': '<p>I get the same error but only for columns with its <code>DefaultValue</code> set to any value (except the default <code>&lt;DBNull&gt;</code>). So the way I got around this issue was:</p>\n\n<ol>\n<li>Column DefaultValue : Type in <code>&lt;DBNull&gt;</code></li>\n<li>Save and reopen the dataset</li>\n</ol>\n'}, {'answer_id': 34353698, 'author': 'ldam', 'author_id': 1492861, 'author_profile': 'https://Stackoverflow.com/users/1492861', 'pm_score': 2, 'selected': False, 'text': '<p>For those finding this via Google and you have a slightly different case where your table has got data and you add a new column (like me), if you create the column and set the datatype in separate statements you also get this same exception. However, if you do it in the same statement, it works fine.</p>\n\n<p>So, instead of this:</p>\n\n<pre><code>var column = myTable.Columns.Add("Column1");\ncolumn.DataType = typeof(int); //nope, exception!\n</code></pre>\n\n<p>Do this:</p>\n\n<pre><code>var column = myTable.Columns.Add("Column1", typeof(int));\n</code></pre>\n'}, {'answer_id': 58379030, 'author': 'Caius Jard', 'author_id': 1410664, 'author_profile': 'https://Stackoverflow.com/users/1410664', 'pm_score': 0, 'selected': False, 'text': '<ul>\n<li>Close the DataSet in the visual designer</li>\n<li>Right click the dataset, choose <code>Open With...</code></li>\n<li>Choose <code>XML (Text) Editor</code></li>\n<li>Find the column in the XML, in your dataset it will look something like:</li>\n</ul>\n\n<pre><code>&lt;xs:element name="DataColumn1"\n  msprop:Generator_ColumnVarNameInTable="columnDataColumn1"\n  msprop:Generator_ColumnPropNameInRow="DataColumn1"\n  msprop:Generator_ColumnPropNameInTable="DataColumn1Column"\n  msprop:Generator_UserColumnName="DataColumn1" \n  type="xs:int" \n  minOccurs="0" /&gt;\n</code></pre>\n\n<ul>\n<li>Change the <code>type="xs:int"</code> to <code>type="xs:decimal"</code></li>\n<li>Save and close the XML editor</li>\n<li>You may need to right click the DataSet again and choose <code>Run Custom Tool</code></li>\n</ul>\n'}, {'answer_id': 67993644, 'author': 'Gustavo Besade', 'author_id': 8954938, 'author_profile': 'https://Stackoverflow.com/users/8954938', 'pm_score': 0, 'selected': False, 'text': '<p>Its an old Question but it still can happen at VS 2019</p>\n<p>Solution:</p>\n<ol>\n<li>Change the DefaultValue to &lt;DBNull&gt;</li>\n<li>Save the Dataset</li>\n<li>Close the DataSet Designer</li>\n<li>Re-Open the Designer</li>\n</ol>\n<p>Now it should be possible to change the type without any problem.</p>\n'}]
['https://Stackoverflow.com/questions/47217', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3123/']