473,804 Members | 3,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create DataSet relation with more than 1 field

I have two tables that are linked by 2 fields (ID1 and ID2). Is it possible
to create this relation once the tables are in a DataSet? I can create a
relation using a single field, but I don't know if this is possible with
multiple fields.

Thanks,

Jan 9 '07 #1
1 2821

Tim Kelley wrote:
I have two tables that are linked by 2 fields (ID1 and ID2). Is it possible
to create this relation once the tables are in a DataSet? I can create a
relation using a single field, but I don't know if this is possible with
multiple fields.

Thanks,
Hi,
This is how you can do .... I have given code snippet. I think
this will be useful for your problem.

DataSet ds;
DataTable dt1;
DataTable dt2;
ds.Tables.Add(d t1);
ds.Tables.Add(d t2);
DataRelation dr1 = new DataRelation("I D1 RELATION",
"PARENTID1" , "CHILDID1") ;
dr1.ParentTable = dt1;
dr1.ChildTable = dt2;
DataRelation dr2 = new DataRelation("I D2 RELATION",
"PARENTID2" , "CHILDID2") ;
dr2.ParentTable = dt1;
dr2.ChildTable = dt2;
ds.Relations.Ad d(dr2);

Jan 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2548
by: John T. Howard | last post by:
Can you issue commands from VB.Net to create and delete databases? I would like to create, delete, and copy MSAccess tables and/or databases from code. Can this be done? Can you show, or point me to some source code? I'm a newbie. TIA John
5
1217
by: Benny Raymond | last post by:
I currently have a relation set up between two tables in my dataset. Sometimes I'd like to set the value in the Foreign Key Field to NULL (if it doesn't refrence the other table at all). Currently i'm getting an error no matter what I try to use: 0 Nothing Convert.DBNull Does anyone have experience in this area? I posted this question a few
5
2631
by: Corno | last post by:
Hi all, If I want to provide a typed dataset from a webservice and if that dataset has relations that are nested (isNested=True), then the relations(keyrefs) are not available in the XSD that is offered. If I set IsNested to false or default, then it is included in the XSD. Is this a bug or by design? Corno
1
1837
by: Computer | last post by:
I brought an XSD into the XMLDesigner. The XSD had two related tables and it looked like this in .Net's XMLDesigner: Table 1 --------- BankItem (Bank Item)
6
1882
by: mike11d11 | last post by:
My program has to tables in it. One is the Accounts table with all personal information and then there is also my Memos table with all the notes for each account. My program displays one record at a time for each account in the dataset table. I now want to show only the notes in the memo file that match with the Accounts table current Account #. I have done some similar to this in Access with a subform linked by account # to account #...
1
1205
by: donet programmer | last post by:
I have a requirement where I need to create a dataset that consists of a table inside a table ( a child table inside a parent table). I am not really familiar with the data relations and not sure how to represent this relation. I did create a schema and it looks good on paper, but when I create a dataset from this schema it does not allow me to write to the child table. I am elaborate more if required. This is what my schema looks...
27
3802
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB updates the same data in all other four tables in the right places. I know it would be possible by using the ForeignKeyConstraint object. I have created the tables using the DataSet Visual Tool and I know it doesn't create any ForeignKeyConstraint obj....
0
1364
by: ~J~ | last post by:
Hi, I really hope someone can help me out here. In relation to this thread ( http://www.thescripts.com/forum/thread349557.html ) I'm having a similar issue and getting nowhere fast! In a nutshell I have a MDI Container which can load up several forms. Upon loading of a form, I want this form to either access or load a dataset and populate controls that have been bound to various fields of the dataset.
4
12454
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.