PC Review


Reply
Thread Tools Rate Thread

Adding columns to a new DataTable

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      9th Aug 2007
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.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
William Vaughn
Guest
Posts: n/a
 
      9th Aug 2007
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)
-----------------------------------------------------------------------------------------------------------------------

"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>


 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      13th Aug 2007
Nathan,

As addition to Bill:

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

Cor

"William Vaughn" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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)
> -----------------------------------------------------------------------------------------------------------------------
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding columns to a new DataTable Nathan Sokalski Microsoft ASP .NET 2 13th Aug 2007 11:42 AM
pb with adding columns to a datatable Sam Microsoft VB .NET 4 20th Apr 2005 12:10 PM
Adding Columns to DataSet-DataTable out of Position =?Utf-8?B?QXNodG9u?= Microsoft ADO .NET 2 28th Dec 2004 07:43 PM
adding columns to an already-filled datatable? VMI Microsoft C# .NET 1 6th Oct 2004 06:20 PM
adding columns to datatable with conditionals PK Microsoft ASP .NET 0 29th Mar 2004 03:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:31 AM.