Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Datarows are moved instead of copy

Datarows are moved instead of copy

Scheduled Pinned Locked Moved Windows Forms
helptutorial
2 Posts 2 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sabahat Hussain
    wrote on last edited by
    #1

    I wanted to have button through which user can copy the [order details] from one order id to anoth order id. For example order id: 10248 have 10 detail item and I wanted all these items to append in order id: 200. My problem is that below mentioned code is copying the detail items but it also removes the source detail record. Any clue! -------------------------------------------------------------------- Private Sub btnCopyOrderID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopyOrderID.Click Dim DataTable2 As DataTable = New DataTable DataTable2 = obj.GetDataSet.Tables(1).Clone ' ' copy required record into a new table: DataTable2 For Each MydataRow In obj.GetDataSet.Tables(1).Select("OrderID = " & xcopyOrderID.Text) DataTable2.ImportRow(MydataRow) Next MydataRow ' ' change order id in DataTable2 For i = 0 To DataTable2.Rows.Count - 1 DataTable2.Rows(i).Item("OrderID") = OrderID.Text Next ' 'paste records from DataTable2 to Original Table For Each NewdataRow In DataTable2.Rows obj.GetDataSet.Tables(1).ImportRow(NewdataRow) Next NewdataRow End Sub

    D 1 Reply Last reply
    0
    • S Sabahat Hussain

      I wanted to have button through which user can copy the [order details] from one order id to anoth order id. For example order id: 10248 have 10 detail item and I wanted all these items to append in order id: 200. My problem is that below mentioned code is copying the detail items but it also removes the source detail record. Any clue! -------------------------------------------------------------------- Private Sub btnCopyOrderID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopyOrderID.Click Dim DataTable2 As DataTable = New DataTable DataTable2 = obj.GetDataSet.Tables(1).Clone ' ' copy required record into a new table: DataTable2 For Each MydataRow In obj.GetDataSet.Tables(1).Select("OrderID = " & xcopyOrderID.Text) DataTable2.ImportRow(MydataRow) Next MydataRow ' ' change order id in DataTable2 For i = 0 To DataTable2.Rows.Count - 1 DataTable2.Rows(i).Item("OrderID") = OrderID.Text Next ' 'paste records from DataTable2 to Original Table For Each NewdataRow In DataTable2.Rows obj.GetDataSet.Tables(1).ImportRow(NewdataRow) Next NewdataRow End Sub

      D Offline
      D Offline
      David Sofia
      wrote on last edited by
      #2

      Hi there, When I have thrown nil-Exceptions with the MOF then any iteration requested is about empty data. Struct Real Nil -> repeated Dave

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups