Adding columns to a new DataTable

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

I have a new DataTable that I want to add columns to. I have found that you
need to do this using the DataColumnCollection class, but I am still having
trouble doing this. Can somebody give me an example? Thanks.
 
W

William Vaughn

On page 535 you'll find an example kinda like this:

Dim dt As New DataTable
Dim dc As New DataColumn("MyColumnName", GetType(Integer))
dt.Columns.Add(dc)

The DataTable can be a new one (like this) or an existing DataTable
populated by Fill or Load.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 
C

Cor Ligthert [MVP]

Nathan,

As addition to Bill:

Be aware that using the standard procedures an added column will never be
written to the database.

Cor
 

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

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top