How to merge two column which are already exist in one datatable?

Go To StackoverFlow.com

0

I have one datatable. In that table I have columns named [Total Day], [Present day], and [leave]. Data are as follows:

[Total Day], [Present day], [leave]
   30           25             5
   30           26             4

Now i want to concatenate those three columns in one another column. I want output something like this:

[Total Day] [Present Day] [Leave]  [TotalDay    PresentDay  Leave]
30           25             5      30 VBCrLf    25 VBCrLf     5
30           26             4      30 VBCrLf    26 VBCrLf     4
2012-04-05 15:00
by AB Vyas
This is asp.net net. Do you want vbCrLf for the delimiter, or
- Joel Coehoorn 2012-04-05 15:06
Do you want to do this in the database or the client code - Oded 2012-04-05 15:07
joel-coehoorn and Oded i want to do in code behind not in Database side and between that i want one VbCrLf or
anything but i want it for PDF print so that in pdf i pring each value in new line in same cell... - AB Vyas 2012-04-06 04:11
Please friend Help me out .. thanks in advanc - AB Vyas 2012-04-06 04:14


1

table.Columns.Add("TotalDay    PresentDay  Leave", GetType(String), "[Total Day] + '" & vbCrLf & "' + [Present Day] + '" & vbCrLf & "' + [Leave]")

Assuming that the square brackets are not part of the column name, if they are, use "[[Total Day\]]" etc. For details, see: http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

2012-04-05 18:29
by tore


0

SELECT [Total Day], [Present Day], [Leave], 
       [Total Day] + '\n' + [Present Day] + '\n' + [Leave] As [TotalDay PresentDay Leave]
FROM MyTable
2012-04-05 15:08
by Joel Coehoorn
Issue is in Code Behind DataTable class - Pankaj 2012-04-05 16:06
Ads