Вопрос

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
Это было полезно?

Решение

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

Другие советы

SELECT [Total Day], [Present Day], [Leave], 
       [Total Day] + '\n' + [Present Day] + '\n' + [Leave] As [TotalDay PresentDay Leave]
FROM MyTable
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top