111,126
社区成员
发帖
与我相关
我的任务
分享
DataSet ds = GetData();
ds.Relations.Add ( "EmployeesInfo" , ds.Tables [ "dsTable" ].Columns [ "LoanBh" ] ,
ds.Tables [ "dsTable1" ].Columns [ "LoanBh" ] );
BindingSource masterBindingSource = new BindingSource ( );
BindingSource detailsBindingSource = new BindingSource ( );
masterBindingSource.DataSource = ds;
masterBindingSource.DataMember = "dsTable";
detailsBindingSource.DataSource = masterBindingSource;
detailsBindingSource.DataMember = "EmployeesInfo";
this.dgvMaster.DataSource = masterBindingSource;
this.dgvDetails.DataSource = detailsBindingSource;
if ( ds.Tables [ "dsTable" ].Rows.Count == 0 )
{
ds.Tables [ "dsTable1" ].Clear ( );
}
DECLARE @COUNT VARCHAR(50)
select @COUNT = count(*) from 主 where 查询条件
if(@COUNT >0 )
begion
select * from 主 where 查询条件
select * from 子 where 查询条件
end
DataRelation relation = new DataRelation ("EmployeesInfo" , ds.Tables [ "dsTable" ].Columns [ "LoanBh" ] , ds.Tables [ "dsTable1" ].Columns [ "LoanBh" ] );
ds.Relations.Add (relation);