Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,

please guide me, how copy a datatable value to dataset datatable. my sample code is below:

VB
dim dt as new datatable
dim ds as dataset

.
.
.
.

ds.tables("Name")=dt


But it returns the error 'Property item is ready only'.

Thanks
Posted
Updated 21-Jul-21 4:43am

Use the Add method:

VB
ds.Tables.Add(dt)
 
Share this answer
 
Comments
Shanmugam Vasu 28-Aug-12 8:44am    
Thanks for your reply, i want to copy the datatable(dt) to particular datatable(ex: Name) in the dataset. because i want to set the name datatable to datasource of my report
Member 14180938 21-Jul-21 10:42am    
ds.Tables.Add(dt.Copy)
You can use DataTable.Copy()[^] method.
 
Share this answer
 
Comments
Shanmugam Vasu 28-Aug-12 8:45am    
Thanks for your reply, i want to copy the datatable(dt) to particular datatable(ex: Name) in the dataset. because i want to set the name datatable to datasource of my report
Use this is the easiest way to copy datatable to another dataset

ds.Tables.add(dt.copy)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900