private DataView CreateDataView() { SqlDataAdapter cmd=null; DataSet ds=null; string cmdSelect = "Select * from table1"; string cmdSelect1 = "Select * from table2";
cmd = new SqlDataAdapter(cmdSelect, Conn); ds = new DataSet(); cmd.Fill(ds, "ACCOUNT");
if(Conn.State != ConnectionState.Closed) Conn.Close(); cmd=new SqlDataAdapter(cmdSelect1, Conn); cmd.Fill(ds, "ACCOUNT1");
DataTable dtParent=ds.Tables["ACCOUNT"]; DataTable dtChild=ds.Tables["ACCOUNT1"]; DataRow dr; for(int i=0;i<dtChild.Rows.Count;i++) { dr=dtParent.NewRow(); for(int j=0;j<dtParent.Columns.Count;j++) { dr[j]=dtChild.Rows[i][j]; } dtParent.Rows.Add(dr); } return ds.Tables["ACCOUNT"].DefaultView; } |