title: Can I remove a column if it's part of a primary key?
body: <p>I need to remove blank columns or columns ending in "ID" but I'm getting an error stating Cannot remove this column, because it's part of the primary key. Here is my code, any help is much appreciated.</p>
  
  <pre><code>' Remove blank columns or columns ending in "ID"
            If objColumn.ColumnName = "" OrElse (objColumn.ColumnName.Length &gt; 1 AndAlso objColumn.ColumnName.Right(2) = "ID") Then
                  objColumnsToDelete.Add(objColumn)
              End If
          Next
  
          For Each objDelCol As System.Data.DataColumn In objColumnsToDelete
              dtExport.Columns.Remove(objDelCol)
          Next
  </code></pre>