You must Sign In to post a response.

C# . net+ datatable.importrow

hi,
i wnat to impoet rows from a datatable but not affecting tae datatable.
can i perform datarow copy or clone?

thanks


Comments

Author: D.Jeya kumar(JK)18 Jun 2009 Member Level: Gold   Points : 2

Hi,


Do you want to copy a row from one table to another table?

Regards
JK

Author: Viji RAJKUMAR18 Jun 2009 Member Level: Gold   Points : 2

Hi,

Use ImportRow to import rows from another table

** You can use DataTable.Load method to load data from a IDataReader
object, which can be created through DataTable.CreateDataReader

Also when load data into datatable, you should call BeginLoadData,
EndLoadData so as to turn off event notification(improve performance

Author: D.Jeya kumar(JK)18 Jun 2009 Member Level: Gold   Points : 2

Hi,


check the below sample code. it might help you or give you an idea to use the import row


//Fill the datatable before using the sample code
datatable dtNodeGridLoadFiles = new datatable();
foreach (DataRow drOnGrid in dtOnGrid.Rows) {
if ((drOnGrid != null)) {
if (drOnGrid .Length > 0) {
dtNodeGridLoadFiles.ImportRow(drOnGrid);
}
}
}



Regards
JK

Author: Aarati18 Jun 2009 Member Level: Gold   Points : 2

hi,
Thanks for yur reply. but . in this way the row is imported form the datatable . while there is no datarow in the original datatable how can i solve the problem .

i need to copy datatable with same data and structure but when i make change in copy there is change in original datatable. how can i copy datatble in the way thet oriiginal and copy doesnot get affected by the changes in other.

Author: Raaz18 Jun 2009 Member Level: Silver   Points : 2

DataTable dtNew = new DataTable();
dtNew.Merge(dtOrginal);

if u make any chnages in dtNew table, it will not effect to the dtOrginal.

Regards
Raaj


Sign In to post your comments