471,073 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

how can I create a copy of a DataRow that lasts after datatable is cleared?

If I have just filled a DataTable in a typed DataSet with a single
row, is there a way I can make a copy of that row, so that I can clear
the DataTable in that DataSet and use it for another query, but my
copy of the row will be preserved?

If I try to do something like this:

this.oleDbWbuserAdapter.SelectCommand.CommandText =
"SELECT * FROM wbuser where username='bennett';";
dsLocalDataSet.wbuserRow currRow = ds1.wbuser[0];


this.oleDbWbuserAdapter.SelectCommand.CommandText =
"SELECT * FROM wbuser where username='bennett2';";

// this won't work; reference to currRow is no longer valid

(where dsLocalDataSet is a typed DataSet class containing a table
called "wbuser") then this won't work, because currRow just refers to
row zero of the ds1.wbuser DataTable, and when I call ds1.Clear(),
currRow disappears.

On the other hand DataRow doesn't appear to have a built-in method for
making a copy of itself. The ds1.wbuser DataTable class does have a
member method called NewwbuserRow() generated for it, but it doesn't
take any arguments, so I can't pass an existing wbuser row to it and
make a copy. Is there some way to make a copy that I can refer to
later in the code, even after I've cleared out the dataset object and
reused it for another query? Or do I have to use a different dataset
object for every query, if I want to keep the row objects around so
that I can refer to them later in the code?

Nov 18 '05 #1
0 1127

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by dudi | last post: by
reply views Thread by Kelvin | last post: by
2 posts views Thread by Fredrik Rodin | last post: by
2 posts views Thread by Li Pang | last post: by
6 posts views Thread by Pete Wittig | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.