PC Review


Reply
Thread Tools Rate Thread

Adding datacolumn to filled datatable

 
 
VMI
Guest
Posts: n/a
 
      2nd Nov 2004
I have a a filled datatable with 3 datacolumns and I need to add a 4th
datacolumn that will contain information according to one of the columns.
For example, for one record, Col1, Col2, Col3 will contain "Mr", "John",
"Smith", respectively. The newly-added 4th column (Col4) will evaluate
Col1, and if it says "Mr.", that row wlll contain "Mister" in Col4. If it
says, "Ms", it'll contain, "Miss", and so on.
How can I do this?

Thanks.


 
Reply With Quote
 
 
 
 
VMI
Guest
Posts: n/a
 
      2nd Nov 2004
DataColumn col_type = new DataColumn("Type");

myTable.Columns.Add(col_type);

col_type.Expression = "IIF(Col1='Mr', 'Mister', 'Miss');

http://msdn.microsoft.com/library/de...ssiontopic.asp



"VMI" <(E-Mail Removed)> wrote in message
news:uR$(E-Mail Removed)...
>I have a a filled datatable with 3 datacolumns and I need to add a 4th
>datacolumn that will contain information according to one of the columns.
>For example, for one record, Col1, Col2, Col3 will contain "Mr", "John",
>"Smith", respectively. The newly-added 4th column (Col4) will evaluate
>Col1, and if it says "Mr.", that row wlll contain "Mister" in Col4. If it
>says, "Ms", it'll contain, "Miss", and so on.
> How can I do this?
>
> Thanks.
>



 
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
Dataset,Datatable,DataColumn Franck Microsoft C# .NET 4 20th Nov 2007 09:45 PM
Problem adding aggregate datacolumn to datatable Trygve Lorentzen Microsoft ADO .NET 3 30th Nov 2006 08:43 PM
adding columns to an already-filled datatable? VMI Microsoft C# .NET 1 6th Oct 2004 06:20 PM
Extra DataColumn's in DataTable Faz Microsoft ADO .NET 2 19th Nov 2003 06:48 PM
Check Contraints on DataTable or DataColumn John Hui Microsoft ADO .NET 0 12th Sep 2003 10:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:52 AM.