Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Copy datatable into new datatable and rename columns

I have a datatable with the following columns

[start Date]
[Pmt Amount]
[Compounding]

How do I copy 2 of those columns into a new datatable to pass to SQL 2008 as a structured data table

the new datatable would be
startDate
PaymentAmt
ASKER CERTIFIED SOLUTION
Avatar of x77
x77
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note. I write code directly, I don´t verify.

by sample :  where says         row(ccor)    ->    row(ccor(n))

Avatar of Larry Brister

ASKER

You put me on the right track...thanks

Dim dt As New DataTable
dt = ConvertTo(l_lead.Payments)
dt.Columns(0).ColumnName = "LeadType"
blah...blah...blah..

dt.Columns.Remove("LeadType")
dt.Columns.Remove("PaymentStreamID")
blah...blah...blah..

dt.Columns("EventType").SetOrdinal(0)
dt.Columns("StartDate").SetOrdinal(1)
dt.Columns("PmtAmount").SetOrdinal(2)
blah...blah...blah.."