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
|