By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,901 Members | 1,496 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,901 IT Pros & Developers. It's quick & easy.

insert a new column in DataTable at a specified position

P: n/a
I would like to insert a new column in DataTable at a specified position at
runtime.
Unfortunatly, the DataColumnCollection does not expose any method to do this
(like AddAt),Any ideas would be greatly appreciated?
Vinny

Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Is the source DataTable populated? And if so, with how many records? If it
is unpopulated or with a limited number of records, I would create a new
table and copy the existing records.

But there may be other options. What is the source of the original data?
If you're creating the table and/or filling it via a SQL query, can you
reorder the SELECT list to give you the data in the order you want with the
new column already there? You could even consider adding the new column by
way of your select statement such as

SELECT name, address1, NULL AS newColumn, city, state FROM SomeTable

There are probably many other ways to get to what you're trying to do, if
you'd give a little more information.

HTH

DalePres
MCAD, MCDBA, MCSE
"Vinny Vinn" <Vi*******@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
I would like to insert a new column in DataTable at a specified position at
runtime.
Unfortunatly, the DataColumnCollection does not expose any method to do
this
(like AddAt),Any ideas would be greatly appreciated?
Vinny

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.