locked
copy DataRow from one DataTable to another RRS feed

  • Question

  • Hello,

    I have 2 datatables, one is empty and one is not. I need to copy certain row from 1 table to another. here is the code:

     Dim dr1 As DataRow
    Table1 = table2.Clone()
    dr1 = table2.Select("id1=" + strid1 + " ")(0)
    Table1.ImportRow(dr1)

    The problem is that the row dr1 is not imported in the Table1, even after ImportRow, Table1.Rows.Count =0.

    How do I import dr1 into Table1?

    Thanks

    Wednesday, October 31, 2012 6:00 AM

Answers

  • solved it, the problem was that Table1 was module property and Table1.ImportRow(dr1) is calling the Table1.Get, here I had if number of rows=0 to do new DataTable, and I was supposed to check if it is null instead.
    • Marked as answer by Barbi Rio Wednesday, October 31, 2012 9:05 AM
    Wednesday, October 31, 2012 9:05 AM

All replies

  • solved it, the problem was that Table1 was module property and Table1.ImportRow(dr1) is calling the Table1.Get, here I had if number of rows=0 to do new DataTable, and I was supposed to check if it is null instead.
    • Marked as answer by Barbi Rio Wednesday, October 31, 2012 9:05 AM
    Wednesday, October 31, 2012 9:05 AM
  • Hi Barbi,

    Welcome to the MSDN forum.

    Glad to know you have solved your problem.

    Have a nice day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, November 1, 2012 1:29 AM