Master-Detail with many-to-many relationship

D

Darwin S.

I am trying to set up a master-detail relationship
between two grids. I have two problems:
1) The DataTables that are the sources for each grid have
a many-to-many relationship, meaning there is a cross-
reference table between them.
2) The DataTable for the detail grid refences a DataTable
that is alredy referenced by another DataGrid on another
tab in a TabControl and that grid must show a different
set of records.

I have tried many different solutions but nothing so far
has worked. Any suggestions?

Thanks,
Darwin
 
G

Guest

Never mind. I figured it out. Simple solution is to
generate a second dataset.

Darwin
 
G

Gordo

-----Original Message-----
I am trying to set up a master-detail relationship
between two grids. I have two problems:
1) The DataTables that are the sources for each grid have
a many-to-many relationship, meaning there is a cross-
reference table between them.
2) The DataTable for the detail grid refences a DataTable
that is alredy referenced by another DataGrid on another
tab in a TabControl and that grid must show a different
set of records.

Can you create another table with same data and use that ?
I have tried many different solutions but nothing so far
has worked. Any suggestions?

Thanks,
Darwin
.

Darwin;

Since you didn't mention the solutions that you have tried
could you repost and list them ? I might be able to see
something.

Also did you try this from the Microsoft documentation ?

"Many-to-Many Relationships

In a many-to-many relationship, a row in table A can have
many matching rows in table B, and vice versa. You create
such a relationship by defining a third table, called a
junction table, whose primary key consists of the foreign
keys from both table A and table B. For example, the
authors table and the titles table have a many-to-many
relationship that is defined by a one-to-many
relationship from each of these tables to the
titleauthors table. The primary key of the titleauthors
table is the combination of the au_id column (the authors
table's primary key) and the title_id column (the titles
table's primary key)."

Cheers,

Gordo
 
K

Kevin Yu [MSFT]

Yes, Darwin, you can copy the DataSet to a new one by simply calling
DataSet.Copy() method. Here's a reference for DataSet.Copy():

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdatadatasetclasscopytopic.asp

Since you're setting up a master-detail relationship between two grids, the
following sample might be helpful:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbtskcreatingmasterdetailslistwithdatagrid.asp

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: <[email protected]>
| Sender: <[email protected]>
| References: <[email protected]>
| Subject: Master-Detail with many-to-many relationship
| Date: Fri, 31 Oct 2003 11:16:38 -0800
| Lines: 25
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOf44Hmd65ybxyHSYGswJfHduilwA==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65025
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Never mind. I figured it out. Simple solution is to
| generate a second dataset.
|
| Darwin
|
| >-----Original Message-----
| >I am trying to set up a master-detail relationship
| >between two grids. I have two problems:
| >1) The DataTables that are the sources for each grid
| have
| >a many-to-many relationship, meaning there is a cross-
| >reference table between them.
| >2) The DataTable for the detail grid refences a
| DataTable
| >that is alredy referenced by another DataGrid on another
| >tab in a TabControl and that grid must show a different
| >set of records.
| >
| >I have tried many different solutions but nothing so far
| >has worked. Any suggestions?
| >
| >Thanks,
| >Darwin
| >.
| >
|
 
K

Kevin Yu [MSFT]

Hi Darwin,

I'd like to know if this issue has been resolved. I'm still monitoring on
it.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| X-Tomcat-ID: 44913596
| References: <[email protected]>
<[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Kevin Yu [MSFT])
| Organization: Microsoft
| Date: Sat, 01 Nov 2003 02:01:28 GMT
| Subject: RE: Master-Detail with many-to-many relationship
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Lines: 59
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65070
| NNTP-Posting-Host: TOMCATIMPORT2 10.201.218.182
|
| Yes, Darwin, you can copy the DataSet to a new one by simply calling
| DataSet.Copy() method. Here's a reference for DataSet.Copy():
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
| frlrfsystemdatadatasetclasscopytopic.asp
|
| Since you're setting up a master-detail relationship between two grids,
the
| following sample might be helpful:
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
| vbtskcreatingmasterdetailslistwithdatagrid.asp
|
| If anything is unclear, please feel free to reply to the post.
|
| Kevin Yu
| =======
| "This posting is provided "AS IS" with no warranties, and confers no
| rights."
|
| --------------------
| | Content-Class: urn:content-classes:message
| | From: <[email protected]>
| | Sender: <[email protected]>
| | References: <[email protected]>
| | Subject: Master-Detail with many-to-many relationship
| | Date: Fri, 31 Oct 2003 11:16:38 -0800
| | Lines: 25
| | Message-ID: <[email protected]>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="iso-8859-1"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| | Thread-Index: AcOf44Hmd65ybxyHSYGswJfHduilwA==
| | Newsgroups: microsoft.public.dotnet.framework.adonet
| | Path: cpmsftngxa06.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.adonet:65025
| | NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| | X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| |
| | Never mind. I figured it out. Simple solution is to
| | generate a second dataset.
| |
| | Darwin
| |
| | >-----Original Message-----
| | >I am trying to set up a master-detail relationship
| | >between two grids. I have two problems:
| | >1) The DataTables that are the sources for each grid
| | have
| | >a many-to-many relationship, meaning there is a cross-
| | >reference table between them.
| | >2) The DataTable for the detail grid refences a
| | DataTable
| | >that is alredy referenced by another DataGrid on another
| | >tab in a TabControl and that grid must show a different
| | >set of records.
| | >
| | >I have tried many different solutions but nothing so far
| | >has worked. Any suggestions?
| | >
| | >Thanks,
| | >Darwin
| | >.
| | >
| |
|
|
 
D

Darwin S.

I'm not sure if I did it the way I was supposed to. I
could not just clone the dataset so in design mode I just
generated a new dataset using the specific tables I
needed. I needed one of the tables to be slightly
different from one in the original dataset so I needed a
new dataadapter as well. In no case do I need write
access to any of the tables.

To solve the many-to-many master-detail issue, I changed
the detail select statement to do a join with the cross-
reference table and then created a relationship between
the master and detail tables. If I needed to update
these tables this solution would not work.

Darwin
-----Original Message-----
Hi Darwin,

I'd like to know if this issue has been resolved. I'm still monitoring on
it.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| X-Tomcat-ID: 44913596
| References: <[email protected]>
<[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Kevin Yu [MSFT])
| Organization: Microsoft
| Date: Sat, 01 Nov 2003 02:01:28 GMT
| Subject: RE: Master-Detail with many-to-many relationship
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Lines: 59
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65070
| NNTP-Posting-Host: TOMCATIMPORT2 10.201.218.182
|
| Yes, Darwin, you can copy the DataSet to a new one by simply calling
| DataSet.Copy() method. Here's a reference for DataSet.Copy():
url=/library/en-us/cpref/html/
| frlrfsystemdatadatasetclasscopytopic.asp
|
| Since you're setting up a master-detail relationship between two grids,
the
| following sample might be helpful:
|
|
http://msdn.microsoft.com/library/default.asp? url=/library/en-us/vbcon/html/
| vbtskcreatingmasterdetailslistwithdatagrid.asp
|
| If anything is unclear, please feel free to reply to the post.
|
| Kevin Yu
| =======
| "This posting is provided "AS IS" with no warranties, and confers no
| rights."
|
| --------------------
| | Content-Class: urn:content-classes:message
| | From: <[email protected]>
| | Sender: <[email protected]>
| | References: <[email protected]>
| | Subject: Master-Detail with many-to-many relationship
| | Date: Fri, 31 Oct 2003 11:16:38 -0800
| | Lines: 25
| | Message-ID: <[email protected]>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="iso-8859-1"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| | Thread-Index: AcOf44Hmd65ybxyHSYGswJfHduilwA==
| | Newsgroups: microsoft.public.dotnet.framework.adonet
| | Path: cpmsftngxa06.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.adonet:65025
| | NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| | X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| |
| | Never mind. I figured it out. Simple solution is to
| | generate a second dataset.
| |
| | Darwin
| |
| | >-----Original Message-----
| | >I am trying to set up a master-detail relationship
| | >between two grids. I have two problems:
| | >1) The DataTables that are the sources for each grid
| | have
| | >a many-to-many relationship, meaning there is a cross-
| | >reference table between them.
| | >2) The DataTable for the detail grid refences a
| | DataTable
| | >that is alredy referenced by another DataGrid on another
| | >tab in a TabControl and that grid must show a different
| | >set of records.
| | >
| | >I have tried many different solutions but nothing so far
| | >has worked. Any suggestions?
| | >
| | >Thanks,
| | >Darwin
| | >.
| | >
| |
|
|

.
 
K

Kevin Yu [MSFT]

Yes, Darwin,

If one of the tables are different and there's no relation between the two
datasets on different tabs, you need to use a new DataAdapter and generate
another dataset.

Since you don't need to update the data source, the solution to the
many-to-many issue might be right. However, If you need to update the data
table, you can set up a many-to-many relation between two tables and bind
the data relation to the datagrid. You can refer to the link I gave you in
my former posts. You just need to change the relation to many-to-many.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: "Darwin S." <[email protected]>
| Sender: "Darwin S." <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: RE: Master-Detail with many-to-many relationship
| Date: Mon, 3 Nov 2003 17:13:47 -0800
| Lines: 139
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOicOYQQI9iK4x2T+yi+XhZAUlGNw==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65300
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I'm not sure if I did it the way I was supposed to. I
| could not just clone the dataset so in design mode I just
| generated a new dataset using the specific tables I
| needed. I needed one of the tables to be slightly
| different from one in the original dataset so I needed a
| new dataadapter as well. In no case do I need write
| access to any of the tables.
|
| To solve the many-to-many master-detail issue, I changed
| the detail select statement to do a join with the cross-
| reference table and then created a relationship between
| the master and detail tables. If I needed to update
| these tables this solution would not work.
|
| Darwin
|
| >-----Original Message-----
| >Hi Darwin,
| >
| >I'd like to know if this issue has been resolved. I'm
| still monitoring on
| >it.
| >
| >Kevin Yu
| >=======
| >"This posting is provided "AS IS" with no warranties,
| and confers no
| >rights."
| >--------------------
| >| X-Tomcat-ID: 44913596
| >| References: <[email protected]>
| ><[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain
| >| Content-Transfer-Encoding: 7bit
| >| From: (e-mail address removed) (Kevin Yu [MSFT])
| >| Organization: Microsoft
| >| Date: Sat, 01 Nov 2003 02:01:28 GMT
| >| Subject: RE: Master-Detail with many-to-many
| relationship
| >| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| >| Message-ID: <[email protected]>
| >| Newsgroups: microsoft.public.dotnet.framework.adonet
| >| Lines: 59
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.adonet:65070
| >| NNTP-Posting-Host: TOMCATIMPORT2 10.201.218.182
| >|
| >| Yes, Darwin, you can copy the DataSet to a new one by
| simply calling
| >| DataSet.Copy() method. Here's a reference for
| DataSet.Copy():
| >|
| >|
| >http://msdn.microsoft.com/library/default.asp?
| url=/library/en-us/cpref/html/
| >| frlrfsystemdatadatasetclasscopytopic.asp
| >|
| >| Since you're setting up a master-detail relationship
| between two grids,
| >the
| >| following sample might be helpful:
| >|
| >|
| >http://msdn.microsoft.com/library/default.asp?
| url=/library/en-us/vbcon/html/
| >| vbtskcreatingmasterdetailslistwithdatagrid.asp
| >|
| >| If anything is unclear, please feel free to reply to
| the post.
| >|
| >| Kevin Yu
| >| =======
| >| "This posting is provided "AS IS" with no warranties,
| and confers no
| >| rights."
| >|
| >| --------------------
| >| | Content-Class: urn:content-classes:message
| >| | From: <[email protected]>
| >| | Sender: <[email protected]>
| >| | References: <[email protected]>
| >| | Subject: Master-Detail with many-to-many relationship
| >| | Date: Fri, 31 Oct 2003 11:16:38 -0800
| >| | Lines: 25
| >| | Message-ID: <[email protected]>
| >| | MIME-Version: 1.0
| >| | Content-Type: text/plain;
| >| | charset="iso-8859-1"
| >| | Content-Transfer-Encoding: 7bit
| >| | X-Newsreader: Microsoft CDO for Windows 2000
| >| | X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| | Thread-Index: AcOf44Hmd65ybxyHSYGswJfHduilwA==
| >| | Newsgroups: microsoft.public.dotnet.framework.adonet
| >| | Path: cpmsftngxa06.phx.gbl
| >| | Xref: cpmsftngxa06.phx.gbl
| >microsoft.public.dotnet.framework.adonet:65025
| >| | NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| | X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| >| |
| >| | Never mind. I figured it out. Simple solution is
| to
| >| | generate a second dataset.
| >| |
| >| | Darwin
| >| |
| >| | >-----Original Message-----
| >| | >I am trying to set up a master-detail relationship
| >| | >between two grids. I have two problems:
| >| | >1) The DataTables that are the sources for each
| grid
| >| | have
| >| | >a many-to-many relationship, meaning there is a
| cross-
| >| | >reference table between them.
| >| | >2) The DataTable for the detail grid refences a
| >| | DataTable
| >| | >that is alredy referenced by another DataGrid on
| another
| >| | >tab in a TabControl and that grid must show a
| different
| >| | >set of records.
| >| | >
| >| | >I have tried many different solutions but nothing
| so far
| >| | >has worked. Any suggestions?
| >| | >
| >| | >Thanks,
| >| | >Darwin
| >| | >.
| >| | >
| >| |
| >|
| >|
| >
| >.
| >
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top