duplicating a DataRow

  • Thread starter Thread starter Corey Wirun
  • Start date Start date
C

Corey Wirun

Hi All,

I've got a strongly typed DataSet where I want to: traverse the rows in a
table and do a check. If the check is successful, I want to duplicate the
row, tweak a column, then add it to the same table in the DataSet.

What's the most efficient way to do this?

I tried to 'new' a new DataSet-derived DataRow (and hoping to copy a row
into it), but the constructor wanted a DataRowBuilder, which i don't have.
DataRowBuilder appears to be an internal object, not useable by us
developers.

Also, the table has 34 columns and it's a pain in the rear to write all the
code to deal with the DataRow indexes. Is there a better (less typing) way
to do the copy, or do I have to deal with the base DataSet class
exclusively?

Thanks in advance!
Corey.
 
Hi Corey,

Did you try with DataTable.ImportRow?

-
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
 
Hi Corey,

I think Hiha's suggestion that use the DataTable's importRow method is
reasonable and here are some former threads discussing the same problem,
you can also have a look:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=eE6ZPscLEHA.2660%
40TK2MSFTNGP09.phx.gbl&rnum=5&prev=/groups%3Fq%3DDataTable%2Bcopy%2Brow%26ie
%3DUTF-8%26hl%3Den

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=cmb5av0vlvqom4906
fp7qnmi7o5b1vv796%404ax.com&rnum=8&prev=/groups%3Fq%3DDataTable%2Bcopy%2Brow
%26ie%3DUTF-8%26hl%3Den

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=#8787rueDHA.361
6%40TK2MSFTNGP11.phx.gbl&rnum=3&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%
26q%3DDataTable%2Bcopy%2Bdatarow


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
I'll try what you suggested.

Thanks, 'Hiha', err, I mean Miha. ;)

Corey.

Miha Markic said:
Hi Corey,

Did you try with DataTable.ImportRow?

-
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Corey Wirun said:
Hi All,

I've got a strongly typed DataSet where I want to: traverse the rows in a
table and do a check. If the check is successful, I want to duplicate the
row, tweak a column, then add it to the same table in the DataSet.

What's the most efficient way to do this?

I tried to 'new' a new DataSet-derived DataRow (and hoping to copy a row
into it), but the constructor wanted a DataRowBuilder, which i don't have.
DataRowBuilder appears to be an internal object, not useable by us
developers.

Also, the table has 34 columns and it's a pain in the rear to write all the
code to deal with the DataRow indexes. Is there a better (less typing) way
to do the copy, or do I have to deal with the base DataSet class
exclusively?

Thanks in advance!
Corey.
 
;P I saw it too. Sorry for the typing error.

Enjoy the community.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top