Forums » .NET » .NET »

C# . net+ datatable.importrow


Posted Date: 18 Jun 2009      Posted By:: Aarati Profile photo    Member Level: Gold    Member Rank: 967     Points: 1   Responses: 5



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

thanks




Responses

#391146    Author: D.Jeya kumar(JK)      Member Level: Gold      Member Rank: 13     Date: 18/Jun/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi,


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

Regards
JK

Thanks & Regards
D.Jeya Kumar(JK)


 
#391151    Author: Viji RAJKUMAR      Member Level: Gold      Member Rank: 119     Date: 18/Jun/2009   Rating: 2 out of 52 out of 5     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

Regards

VIJI RAJKUMAR
Pls rate my Answer if it was supportive
http://vijirajkumar.blogspot.com


 
#391155    Author: D.Jeya kumar(JK)      Member Level: Gold      Member Rank: 13     Date: 18/Jun/2009   Rating: 2 out of 52 out of 5     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

Thanks & Regards
D.Jeya Kumar(JK)





 
#391165    Author: Aarati      Member Level: Gold      Member Rank: 967     Date: 18/Jun/2009   Rating: 2 out of 52 out of 5     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.


 
#391250    Author: Raaz      Member Level: Silver      Member Rank: 2508     Date: 18/Jun/2009   Rating: 2 out of 52 out of 5     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


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Return to Discussion Forum
Start new thread

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John

Online Members

Roman Goryelov
More...
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India