0

Hi
Ever had the situation where you need to make a copy of a Datatable? Or where you wish to copy a datarow from one datatable to another?

Well here is how by using Clone, Copy and the ImportRow DataTable Methods.

Function Copy_A_Datatable (byref src as datatable) as datatable
'Copies a datatable including Schema, constraints and rows over to another one
dim dt as DataTable
dt = src.Copy
Return dt
End Function

Function Clone_A_Table(byref src as datatable) as datatable
'create new Blank table based on source with same schema etc just no data
dim dt as Datatable
dt= src.clone
return dt 
end function

Sub Import_A_DataRow(byref DR as dataRow, Target as DataTable)
'Imports a datarow of same schema from another table
Target.ImportRow(DR)
end sub
2
Contributors
1
Reply
10
Views
6 Years
Discussion Span
Last Post by sandeepparekh9
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.