473,224 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Dataset relations, MSAccess database

I am building a c# windows forms app to show tables from a ms access
I am using OleDbConnection with Microsoft.Jet.OLEDB.4.0 , 5 datagrids
and some data relations to show on
datagrid1 - all jobs
datagrid2 - receipts for the selected job on dg1
datagrid3 - receipt_items for the selected receipt on dg2
datagrid4 - all categories
datagrid5 - receipt items only for the selected job and for the
selected category (the problem)

The tables are:

id | title

id | title

id | category

id | id_job | id_supplier | title

id | id_receipt | id_category | price

I need some help on the data relation for to filter data to show on

Here is some sample code i am using to crate a data relation. I get an
exception when calling datagrid5.DataMember = value :

dbAdapterJobs = new OleDbDataAdapter("SELECT * FROM jobs ORDER BY title
ASC", dbConnection);
dbAdapterJobs.TableMappings.Add("Table", "jobs");
dbAdapterJobs.Fill(ds); // ds is the DataSet
// Establish the Relationship "RelJobsReceipts"
// between jobs---< receipts
System.Data.DataRelation relJobsReceipts;
System.Data.DataColumn colMaster1;
System.Data.DataColumn colDetail1;
colMaster1 = ds.Tables["jobs"].Columns["id"]; //column must have unique
colDetail1 = ds.Tables["receipts"].Columns["id_job"];
relJobsReceipts = new System.Data.DataRelation("RelJobsReceipts",
colMaster1, colDetail1);
// Establish the Relationship "RelCategoriesReceiptItems"
// between categories ---< receipt_items
System.Data.DataRelation relCategoriesReceiptItems;
System.Data.DataColumn colMaster4;
System.Data.DataColumn colDetail4;
colMaster4 = ds.Tables["categories"].Columns["id"];
colDetail4 = ds.Tables["receipt_items"].Columns["id_category"];
relCategoriesReceiptItems = new
System.Data.DataRelation("RelCategoriesReceiptItem s", colMaster4,
// Databinding for the Grid's
dg1.DataSource = dsView;
dg1.DataMember = "jobs";
dg2.DataSource = dsView;
dg2.DataMember = "jobs.RelJobsReceipts";
dg3.DataSource = dsView;
dg3.DataMember = "jobs.RelJobsReceipts.RelReceiptsReceiptItems" ;
dg4.DataSource = dsView;
dg4.DataMember = "categories";
dg5.DataSource = dsView;
dg5.DataMember = "categories.RelCategoriesReceiptItems"; // EXCEPTION
IN THS LINE: Child list for field categories cannot be created.
Also, how can I costumize the data on the datagrid? i can't do it in
the designer directly.

Thanks in advance.

Jan 4 '06 #1
0 1135

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

Similar topics

by: Walter | last post by:
Hello, I want to fill a dataset with a random database (mdb-database or SQL-server database), from which a don't know the tables, relations or anything. So after this, the dataset will be 1:1...
by: Horatiu Ripa | last post by:
Once defined in SQL a database, with keys, indexes and relations between tables is it possible to create a DataSet to reflect all that? Basically I don't want to reestablish the relations, to set...
by: LC | last post by:
I am on the learn C#. Net in 695 day program. I am just trying to learn stuff. I have MSAccess database with 1 table called 'ParmDate' with 1 column called 'ParmDate' which represents a date for...
by: Oscar Thornell | last post by:
Hi, I have a relativley large/complex typed dataset that contains 7-8 tables and some supporting relational tables (lookups) for many-to-many relations. A good exampel would be a dataset that...
by: Gary | last post by:
I have a DataSet where two tables have a relation (the parent / child relationship is also successfully added to the DataSet Relations collection). I am looking for a way to programmatically...
by: Mr Newbie | last post by:
HI People, Thanks to all who helped me earlier on the subject of @@IDentity. However, I seem to have hit another snagette! My DataSet contains two tables from the SQL Server. lets say Master...
by: Joe | last post by:
Hi I have a dataset with 3 tables and 2 relations Is there a way to when I am at 1 row to tell if there is a relation on that row ??? I have the code hardcoded but try to make it work if the #...
by: don | last post by:
I have written a program to hold a sales contact db. It is written in c# express. an update is sent from head office in xl format, i need to import only the new rows to an access database. I...
by: riyap | last post by:
Hi i have a question regarding a update in msaccess DB using string builder,DATA SET AND DATA RELATIONS can we do that in access DB i have a table in access i need to pass more than 1 record and...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.