PC Review


Reply
 
 
daveL
Guest
Posts: n/a
 
      12th Oct 2008
hello
i have a Datatable i use for a datagridview
when a user selects a row, i return the row to the
calling window (doubleclickevent)

in the calling method i want to set the datarow to a tmp datatable to use
with sqldataadapter updates, inserts
but when i try to add the row to the tmp table
derived from the same physical table in sql schema

i get a error row already belongs to a datatable
is there a way to change the owning table in the datarow
or do i have to create a new datarow from the tmp table
and copy the columns from the Returnd DataRow

Thanks
DaveL



 
Reply With Quote
 
 
 
 
Alberto Poblacion
Guest
Posts: n/a
 
      12th Oct 2008
"daveL" <(E-Mail Removed)> wrote in message
news:5UnIk.4700$(E-Mail Removed)...
> i get a error row already belongs to a datatable
> is there a way to change the owning table in the datarow
> or do i have to create a new datarow from the tmp table
> and copy the columns from the Returnd DataRow


Yes, that's what you have to do, but there is an easy way to do it in a
single line:

theTmpTable.Rows.Add(theDataRow.ItemArray);

"ItemArray" extracts an array of objects with the values of the columns.
That array is then used as an argument for the overload of the Add method
that takes an object[].

 
Reply With Quote
 
DaveL
Guest
Posts: n/a
 
      12th Oct 2008
thanks alot , much appriciated
DaveL

"Alberto Poblacion" <earthling-(E-Mail Removed)> wrote
in message news:(E-Mail Removed)...
> "daveL" <(E-Mail Removed)> wrote in message
> news:5UnIk.4700$(E-Mail Removed)...
>> i get a error row already belongs to a datatable
>> is there a way to change the owning table in the datarow
>> or do i have to create a new datarow from the tmp table
>> and copy the columns from the Returnd DataRow

>
> Yes, that's what you have to do, but there is an easy way to do it in a
> single line:
>
> theTmpTable.Rows.Add(theDataRow.ItemArray);
>
> "ItemArray" extracts an array of objects with the values of the columns.
> That array is then used as an argument for the overload of the Add method
> that takes an object[].
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A DataTable-bound DataGridView throws a low-level Exception whencolumns are sorted, removed and re-added to the underlying DataTable. Sath123 Microsoft Dot NET Framework Forms 1 12th May 2008 12:51 PM
DataTable -> DataView -> Sort -> DataGrid : need related DataTable index Diamonds Microsoft ADO .NET 4 28th Jun 2006 08:23 PM
what is the best way to make a DataTable thread safe? DataTable.AcceptChanges() will throw exception (not documented) Ryan Liu Microsoft C# .NET 3 7th Jun 2006 05:07 PM
Retrieving datarows using DataTable.Select method and adding it to new DataTable C.Anand via DotNetMonster.com Microsoft ADO .NET 4 4th Apr 2005 05:21 PM
How can I use real SQL on a DataTable? i.e. not array of rows using a filter... as in DataTable.Select Dan V. Microsoft C# .NET 3 1st Jul 2004 03:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 PM.