473,513 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dataset relations, MSAccess database

Greetings.
I am building a c# windows forms app to show tables from a ms access
database.
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:

jobs
id | title

suppliers
id | title

categories
id | category

receipts
id | id_job | id_supplier | title

receipt_items
id | id_receipt | id_category | price

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

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
values
colDetail1 = ds.Tables["receipts"].Columns["id_job"];
relJobsReceipts = new System.Data.DataRelation("RelJobsReceipts",
colMaster1, colDetail1);
ds.Relations.Add(relJobsReceipts);
[...]
// 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,
colDetail4);
ds.Relations.Add(relCategoriesReceiptItems);
[...]
// 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.
Pedro.

Jan 4 '06 #1
0 1151

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

Similar topics

0
1328
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...
1
258
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...
2
2890
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...
4
3795
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...
3
1464
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...
9
1715
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...
2
2852
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 #...
3
3050
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...
0
884
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...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7535
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...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
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...
0
5683
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,...
0
4745
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...
0
3232
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...
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.