PC Review


Reply
Thread Tools Rate Thread

Copy a datacolumn - Most code done, Missing one thing though....

 
 
Cade Carvell
Guest
Posts: n/a
 
      10th Jul 2003
Hello,
I am trying to copy a datacolumn from a good table, and append it to
an incoming table that needs to be modified. This incoming table has
data, and I would rather not copy each property one by one, Is thier a
way to get the propertyinfo stuff to work were I can read the property
of a datacolumn, and set it on a new datacolumn...Here is were I am at
in Code:
If Not (TBL.Columns.Contains(DC.ColumnName)) Then
Dim DCNEW As New DataColumn
Dim T As Type
T = DC.GetType
Dim Pi As System.Reflection.PropertyInfo
For Each Pi In
T.GetProperties(System.Reflection.BindingFlags.Public Or
System.Reflection.BindingFlags.Instance)
Dim result As Object
If Pi.CanWrite Then
Try
result = Pi.GetValue(DC,
System.Reflection.BindingFlags.Public Or
Reflection.BindingFlags.Instance Or Reflection.BindingFlags.GetProperty,
Nothing, Nothing, Nothing)
'********Now that I havge the result, how do I get it
back into the new datacolumn?
Catch
Debug.WriteLine(Pi.Name & " = " & "Can't get Value")
End Try
End If
Next
TBL.Columns.Add(DC)
End If

Thanks to anyone who can help me with this.

Cade

 
Reply With Quote
 
 
 
 
Cade Carvell
Guest
Posts: n/a
 
      15th Jul 2003
I found a work around. What it was is that if the second table is
missing some datacolumns based on the first table, I want it to add the
missing data columns in, using all formatting data from the first table.
I ended up working on a PRoperty walker that created the new
datacolumn, and copied attributes (shallow copy) of the datacolumn I
wanted to add to the second table.

Thanks,
Cade

Kathleen Dollard wrote:
> Cade,
>
> I think I am missing something.
>
> It looks like you are trying to get .NET to infer a mapping when there is no
> mapping information. Are hte names of the columsn in the second table the
> same (then it would be dt.Rows(thisrow)(columnName).
>
> Kathleen
>
>
> "Cade Carvell" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>Hello,
>> I am trying to copy a datacolumn from a good table, and append it to
>>an incoming table that needs to be modified. This incoming table has
>>data, and I would rather not copy each property one by one, Is thier a
>>way to get the propertyinfo stuff to work were I can read the property
>>of a datacolumn, and set it on a new datacolumn...Here is were I am at
>>in Code:
>>If Not (TBL.Columns.Contains(DC.ColumnName)) Then
>> Dim DCNEW As New DataColumn
>> Dim T As Type
>> T = DC.GetType
>> Dim Pi As System.Reflection.PropertyInfo
>> For Each Pi In
>>T.GetProperties(System.Reflection.BindingFlags.Public Or
>>System.Reflection.BindingFlags.Instance)
>> Dim result As Object
>> If Pi.CanWrite Then
>> Try
>> result = Pi.GetValue(DC,
>>System.Reflection.BindingFlags.Public Or
>>Reflection.BindingFlags.Instance Or Reflection.BindingFlags.GetProperty,
>>Nothing, Nothing, Nothing)
>> '********Now that I havge the result, how do I get it
>>back into the new datacolumn?
>> Catch
>> Debug.WriteLine(Pi.Name & " = " & "Can't get Value")
>> End Try
>> End If
>> Next
>> TBL.Columns.Add(DC)
>>End If
>>
>>Thanks to anyone who can help me with this.
>>
>>Cade
>>

>
>
>


 
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
Copy a Datacolumn from a table to another Manuel Microsoft C# .NET 3 3rd Oct 2007 04:11 AM
what simple thing am i missing.? =?Utf-8?B?cGNhaA==?= Windows XP General 6 7th Jan 2006 02:05 PM
binding datacolumn to another datacolumn in a datagrid bpdace Microsoft C# .NET 0 23rd Nov 2005 03:59 PM
Copy DataColumn Between Tables? localhost Microsoft Dot NET Framework 3 9th Dec 2004 11:15 AM
Copy Child DataTable?? Copy a DataColumn?? System.Data is frustrating... Cip Microsoft ADO .NET 1 27th Feb 2004 05:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 AM.