How to get All Columns(Any Type) from Table1 To One Column(As String) On Table2 _ 'Linq'

Mansour_Dalir 2,016 Reputation points
2024-01-12T19:33:45.3766667+00:00
   Dim Table1 As New DataTable
        Table1.Columns.Add("C1")
        Table1.Columns.Add("C2")
        Table1.Columns.Add("C3")
        Table1.Rows.Add({1, "A","C"})
        Table1.Rows.Add({2, "B","D"})
        Table1.Rows.Add({3, "C","D"})

   Dim Table2 As New DataTable
    Dim sttSeparator as String="<>" 'Use between columns
'Need Result
  Table2.Columns.Add("AllColumnsTable1") 'As String
  Table2.Rows.Add("1<>A<>C")
  Table2.Rows.Add("2<>B<>D")
  Table2.Rows.Add("3<>C<>D")

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,782 questions
Excel Management
Excel Management
Excel: A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.Management: The act or process of organizing, handling, directing or controlling something.
1,759 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 120K Reputation points
    2024-01-12T21:25:20.14+00:00

    For example:

    Table1.AsEnumerable.
        Select(Function(r) String.Join(strSeparator, r.ItemArray.Select(Function(i) i.ToString))).
        ToList.ForEach(Sub(r) Table2.Rows.Add(r))
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.