Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Database & Reporting

Post new topic   Reply to topic
[RESOLVED] - merging two columns together in a DataTable...
View previous topic :: View next topic  
Author Message
oasisok
Newbie


Joined: 15 Sep 2004
Posts: 7
Location: Oklahoma

PostPosted: Sep 17th, 2004 10:51 AM    Post subject: [RESOLVED] - merging two columns together in a DataTable... Reply with quote

I am pretty weak on using databases (obviously). I have a DataSet that has two tables in it. I need to get columns from another table and combine them into one of the tables in the dataset. What is the easiest way to do this?

James


Last edited by oasisok on Sep 29th, 2004 01:48 PM; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Sep 18th, 2004 01:34 AM    Post subject: Reply with quote

Hi oasisok,

I believe what you need is the ItemDataBound I use it to display content
from multiple tables.

Here is an example

[vb:1:4390356074]Private Sub displaymembers_ItemDataBound(ByVal sender As
System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
_
Handles displaymembers.ItemDataBound

If Not CType(e.Item.FindControl("accessRole"),
System.Web.UI.WebControls.Label) Is Nothing Then
Dim _AccessRole As Label = CType(e.Item.FindControl
("accessRole"), System.Web.UI.WebControls.Label)
' Lookup the role (You could also move this find code into
the manager class for reuse)
Dim _Role As Roles
For Each _Role In _Roles
If _Role.role_id = _AccessRole.Text Then
' Replace with the roles name
_AccessRole.Text = _Role.role_name
Exit For
End If
Next
End If

Dim _Name As String = CType(DataBinder.Eval
(e.Item.DataItem, "FirstName"), String) & " " & CType(DataBinder.Eval
(e.Item.DataItem, "LastName"), String)

CType(e.Item.FindControl("Name"), Label).Text = _Name

End If

End Sub[/vb:1:4390356074] I am not exactly sure how it all works but feel free to write back to me if you require further help.

I hope this helps you out.

Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
oasisok
Newbie


Joined: 15 Sep 2004
Posts: 7
Location: Oklahoma

PostPosted: Sep 22nd, 2004 09:40 AM    Post subject: Reply with quote

I checked the code and I really don't understand it at all. I figured out how to add a column to a table by using the DataColumnCollection.add. I still can't figure out how to take the data from one column and add it to a new column in a different table.

I don't want to add the value through the DataGrid (as shown in the sample code), I want this done before the DataSet is set up on the DataGrid.
Back to top
View user's profile Send private message Visit poster's website
oasisok
Newbie


Joined: 15 Sep 2004
Posts: 7
Location: Oklahoma

PostPosted: Sep 29th, 2004 01:44 PM    Post subject: [Resolved] merging two columns together in a DataTable... Reply with quote

Just FYI, I was able to figure it out. Instead of trying to add columns to a table that was already created, I found out I had to create a new dataset and datatable. then take the data from the tables I already have and add them to the new table. It takes a lot of code, but that's the best way to do it.

Just thought I'd let y'all know.

James
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic