Last post Jul 09, 2010 01:44 AM by reven_gr
Jul 08, 2010 01:17 AM|reven_gr|LINK
i am declaring a public variable in a form class like this
public globalTable as datadable = new datatable
then i am making 2 local variables in a function like this
dim datatable1 as datatable = globaltable
dim datatable2 as datatable = globaltable
the problem is that when i am altering inside the function the datatable1 then datatable2 and globaltable are altered as well and are equal to datatable1.
why is that happening?
how can i asign only the values of globaltable to the local tables?
Jul 08, 2010 11:43 AM|sansan|LINK
Datatable2 and DataTable1 will share the same reference.
That's why when you update one table, others will be reflected.
you can achieve the functionality like this
Dim dt1 As New DataTable()
Dim dt2 As New DataTable()
dt2 = dt1.Copy()
For copying DataRows between two tables, Check this link:
Jul 09, 2010 01:44 AM|reven_gr|LINK
yeap that was it... thanks