DataTable column question

  • Thread starter Thread starter Mika M
  • Start date Start date
M

Mika M

Hi!

It's easy to add Columns into DataSet DataTable for example like this way
....

ds.Tables("MyTable").Columns.Add("MyColumn", GetType(Integer))

.... but how can I remove this column of the DataSet which was created
earlier by code? Do I have to create whole new DataSet table again?

I mean something like ds.Tables("MyTable").Columns.Remove("MyColumn") -
ofcource it's not possible to do like this way :)

I tried ... ds.Tables("MyTable").Columns("MyColumn").Dispose() ... but it
doesn't seem to do what I want.
 
Try this to see if it does what you want.

dim col as DataColumn =
ds.Tables("MyTable").Columns("MyColumn")

ds.Tables("MyTable").Columns.Remove(col)

===========================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools
 
this works here

Dim d As New DataTable

d.Columns.Add("mycolumn")

d.Columns.Remove("mycolumn")

HTH
 
Oh boys! I was really like ...

ds.Tables("MyTable").Columns.Remove("MyColumn")

I did it correct way earlier. In fact problem was few lines before this line
:)

Sorry for bothering with this!
 
Back
Top