Reputation: 3437
I'm wondering if anyone could explain this to me:
I create a datarow with data from one of my databases
DataRow table = sessions.Tables["Sessions"].Rows[position];
I then make some changes to it and use the update command like this:
da.Update(sessions, "Sessions");
My question is, why does the "Sessions" database get updated with the value from "DataRow table"? I just took the values out..
What if I would like to make DataRow table1 and DataRow table2, change them both and later decide which one to use?
The rest of the code is in this thread if needed.
Inserting a row into a database
Thanks!
Upvotes: 0
Views: 111
Reputation: 81610
table1 and table2 and etc are all referencing the same DataRow objects in the table.
When you make a variable equal to an object (DataRow), it's only holding a reference to that object.
If you want table1 or table2 to just have a copy of the DataRow, then you would have to create a new DataRow and copy the columns and data accordingly.
Upvotes: 2