The following is code snippet for your reference:
==============
'Create a new DataSet and add DataTable and DataColumn objects.
Dim ds As New DataSet()
'Create arrays that reference the DataColumn objects
'on which we'll base the new DataRelation.
Dim colsParent, colsChild As DataColumn()
With ds.Tables("ParentTable")
colsParent = New DataColumn() {.Columns("ParentColumn1"), _
.Columns("ParentColumn2")}
End With
With ds.Tables("ChildTable")
colsChild = New DataColumn() {.Columns("ChildColumn1"), _
.Columns("ChildColumn2")}
End With
'Create the new DataRelation.
Dim rel As DataRelation
rel = New DataRelation("MultipleColumns", colsParent, colsChild)
ds.Relationships.Add(rel)
================
Sincerely,
Kevin
Microsoft Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! -
www.microsoft.com/security
--------------------
| From: "Rob Edwards" <
[email protected]>
| References: <#
[email protected]>
<#
[email protected]>
| Subject: Re: Joining Tables
| Date: Mon, 4 Aug 2003 08:11:28 -0400
| Lines: 65
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: 206.211.101.9
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:57370
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| This is certainly where my inexperience shows....I have looked at the
| DataRelation object and can't find a way to create an inner-join on the
two
| tables.
|
| I've created the two DataAdapters and populated a single dataset with both
| of the tables. I opened the vxd file and created a relationship, making
the
| servername from the ServerDatabase table the primary.
|
| What I can't find at this point is a way to actually create an inner join
| between the two tables so all the records from the server database appear,
| and only those records in the SMS database that match. I haven't placed
any
| constraints on the data and cannot find any reference in the relation
object
| on how to join the tables.
|
| Thanks for taking the time to respond... it is very much appreciated.
|
| Rob
|
| | > Hmm, since you're posting to the ADO.NET ng I assume you want to try and
| do
| > this programmatically? If os, how about retrieving the data from one
| > server/database/tables using one DataAdapter and then the other data
using
| > another DataAdapter. Fill the data into the same DataSet as seperate
| tables
| > and create relations between them?
| >
| > --
| > Carsten Thomsen
| > Enterprise Development with Visual Studio .NET, UML, and MSF
| >
http://www.apress.com/book/bookDisplay.html?bID=105
| > | > > I have two seperate SQL Servers, one is an SMS server and the other
is a
| > > server that holds our ServerDatabase application.
| > >
| > > What we are trying to do is reconcile the data in SMS with the data
that
| > is
| > > manually keyed into our server database.
| > >
| > > I have written some views on both SQL Servers to display the unique
| value
| > > (Netbios_Name0 in SMS and ServerName in ServerDB).
| > >
| > > At this point I want to create a 1-1 relationship between the two
tables
| > so
| > > I can see what is in SMS but not is ServerDB.. likewise what's in
| ServerDB
| > > but not in SMS.
| > >
| > > I'd like to present this in a datagrid so they are side-by-side.
| > >
| > > I have played with datasets, data relations, joinviews, etc... to no
| > avail.
| > >
| > > Any input or advise would be greatly appreciate.
| > >
| > > Thanks,
| > >
| > >
| >
| >
|
|
|