0

how to copy data from datatable to table in dataset i ry this but its readonly property

ds.datatable1=newdt.copy
Jagmag
  • 10,283
  • 1
  • 34
  • 58
new
  • 61
  • 1
  • 2
  • 6
  • Can you be a bit more explicit about what you are trying to do here? BTW, copy is a method so it should be `newdt.Copy()`; note the brackets at the end. Also what kind of dataset is `ds`? I am pretty sure the standard Dataset class has no property called `datatable1` – Jagmag Oct 31 '10 at 09:16
  • ds is variable name for my dataset and datatable1 is table alrady created by my in designer and i want to fill it from another datatable , the brackets does not matter cause i am using vb.net ,the problem i cant use dataset.innertable=datatable.copy – new Oct 31 '10 at 09:31
  • Just a possible duplicate of [http://stackoverflow.com/questions/4897080/...][1] – Ibad Baig Jan 20 '13 at 12:11

2 Answers2

0

if datatable1 is a pre-existing datatable in your code and you want to fill it from another datatable newdt, then just doing datatable1 = newdt.copy should suffice.

Remove the ds.from your code. If you already have a reference to the datatable in your dataset i.e. dataTable1, then you can just copy into it directly as above

Jagmag
  • 10,283
  • 1
  • 34
  • 58
-1
DataTable newdt = ds.datatable1;

newdt = Fill Datatable form DB;

ds.datatable1.TableName = "datatable1";