471,317 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 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 1062

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Horatiu Ripa | last post: by
4 posts views Thread by Oscar Thornell | last post: by
2 posts views Thread by Joe | last post: by
3 posts views Thread by don | last post: by
reply views Thread by rosydwin | last post: by

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.