Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 4th, 2005, 08:10 AM
Authorized User
 
Join Date: Dec 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default create a relation betwn 2 tables in a dataset



--------------------------------------------------------------------------------

Hi

In c-sharp windows form,
create two xml files with some sample data in it.also to have a forign key in the table.
Then read them into the dataset.so your dataset should have two tables.Then create a
 relation betwenn those two tables in the dataset.
then place a datagrid and display it.

I am new to c#, so i am learning right now.

In a form , i had designed with a datagrid and a button.
now i have added a datset
and
coded as fllows


private void button1_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
DataSet xml1 = new DataSet();
xml1.ReadXml("C:\\CDEV\\relationcosttypeandcode\\c ost_code.xml");
DataTable dt1 = xml1.Tables["cost_code"].Copy();

DataSet xml2 = new DataSet();
xml2.ReadXml("C:\\CDEV\\relationcosttypeandcode\\c ost_type.xml");
DataTable dt2 = xml2.Tables["cost_type"].Copy();
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);


DataColumn parentCol = ds.Tables["cost_code"].Columns["cost_type"];
DataColumn childCol = ds.Tables["cost_type"].Columns["cost_type"];

DataRelation relTable1Table2;
relTable1Table2 = new DataRelation("cost_typecost_code", parentCol, childCol);
ds.Relations.Add(relTable1Table2);

dataGrid1.DataSource = ds;

}


after running this i get a error when clicking the button

"Column argument cannot be Null".



Pls any one help me to do this


d h o l
__________________
SureShot
 
Old August 9th, 2005, 09:17 AM
Registered User
 
Join Date: Oct 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you sure that either PrimaryKey or ForeignKey values are not null or empty string on the datasets that you are refering?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic tables in DataSet melvik C# 9 September 26th, 2006 06:53 AM
Creat a dataview and dvlop relaton betwn 2 tables dhol General .NET 5 August 11th, 2005 06:46 AM
Create a report from multiple tables in a Dataset verdun Crystal Reports 4 May 12th, 2005 09:20 AM
dataset with multiple tables Bhavin Crystal Reports 2 October 8th, 2004 09:18 AM
find relation in dataset with c# kobystud C# 2 April 21st, 2004 01:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.