Shout !


Free shoutbox @ ShoutMix

BlogMalaysia.com

DataTable

Ok guys , today i want to share some tricks for DataTable .. Simple but useful

1. Copy Structure from another DataTable
Keyword : Clone
Usage : DataTable2 = DataTable1.Clone
Note : This method will only copies structure , schema & constraint from another DataTable , but not data

2. Copy Structure + Data from another DataTable
Keyword : Copy
Usage : DataTable2 = DataTable1.Copy
Note : Copies both structure and data from another DataTable

3. Combining two DataTables
Keyword : Merge
Usage : DataTable1.Merge DataTable2
Note : Sometimes we have 2 DataTables with same structure but different data , so we can use this method to combine the data into one DataTable (Both DataTable MUST have same structure , schema & constraint)

4.1 Copy DataRow from DataTable into another DataTable
Keyword : ImportRow
Usage : DataTable2.ImportRow (DataTable1.Rows(IndexOfRow))

4.2 Copy DataRow from DataTable into another DataTable
Keyword : ItemArray
Usage : DataTable2.Rows.Add Row.ItemArray
Note : This one maybe more useful compare to ImportRow , when we have to loop for each row in DataTable , copy it into another DataTable without knowing the row's index

1 ulasan:

peah @ peps berkata...

..apit..mana lu punye shout out box...tak de..