Hi all fri,
here i have problem about data relation in ms sql.
i have 2 tables, A and B
A _ JobID (pk)
B _ JobID
i want to make one-to-one relation in dataset designer
Q1. how to set it? ( for me, 1-many is ok)
after i 1-1 relation in designer,
for (int i = 0; i < gridView1.SelectedRowsCount; i++)
{
if (gridView1.GetSelectedRows()[i] >= 0)
rows.Add(gridView1.GetDataRow(gridView1.GetSelectedRows()[i]));
}
for (int j = 0; j < rows.Count; j++)
{
DataRow selectedRow = gridView1.GetFocusedDataRow();
bRow= selectedRow as MyDataSet.BTableRow;
DataRow parents = bRow.GetParentRow(dataRelation);
}
i have set dataRelation variable like this
string relation = "ATable_BTable";
DataRelation dataRelation = MyDataSet.BTable.ParentRelations[relation];
In designer, i set correct key column, foreign key column, parent table and child table.
But what's wrong in my code, i got null value in parents datarow although there are 1-1 mapping in DataTable(Database) .
I used the similar way in 1-many relation in other two tables that use the "ChildRelation" .
My tools visual studio 2010, ms sql , c#
Anyone wants to help me? I spent nearly one day :( so bad
thanks in advance