DataTable column question

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.
 
C

ClayB [Syncfusion]

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
 
E

enrico sabbadin @ sabbasoft

this works here

Dim d As New DataTable

d.Columns.Add("mycolumn")

d.Columns.Remove("mycolumn")

HTH
 
M

Mika M

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top