Adding a line to a DataTable using DataTable.ImportRow

When you’re working with DataTables in .NET, copying rows between tables sounds trivial—until you run into schema differences, missing defaults, or values that mysteriously refuse to come along for the ride. That’s where DataTable.ImportRow earns its keep. It provides a safe, reliable way to clone an existing DataRow—preserving its state, values, and version information—and insert it into another table with the same structure.

This article provides a quick code example of how to use ImportRow

Please follow the link at the top of the page to the .NET Development menu page and familiarize yourself with how these articles are stored by technology. That way you can find it when you need it.

Related Articles

... and you 'll find more on the NET Development Menu

 

Dim strQuery As String = String.Format("itemnmbr = '{0}'", strItemNumber)
Dim rows() As DataRow = oDT.Select(strQuery)
If rows.Length = 0 Then
    oDTAdd = SPs.fp_InventoryStockingPO4_2(strItemNumber, strLocationCode, strVendorID, strItemClass, "both", 0, App.ConnectionString).getTable
    oDT.ImportRow(oDTAdd.Rows(0))
End If

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences