954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Copying datatables and datarows

0
By George Waddell on Apr 12th, 2011 8:23 pm

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

nice

sandeepparekh9
Posting Whiz
367 posts since Dec 2010
Reputation Points: 123
Solved Threads: 71
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You