0

Hi,

I have a dataset which is having 5 tables. I want to get only two tables from that dataset and assign into a single datagrid. How can i do this?

Thanks in advance...

3
Contributors
4
Replies
7
Views
7 Years
Discussion Span
Last Post by reach_yousuf
0

Try this Merge option,
ds.Merge(DataSet);

Splitting that two datatables in separate dataset.

0

Hi Chandru, Thank you very much for your kind reply. I did that method, but in that my problem is, i have 3 rows, 8 columns in table1 and 3 rows, 8 columns in table2. First 2 columns of both the tables are same. Always i will get row count is same for both the tables. So, if i use this merge method then it creates a table with 6 rows, and also after the 8th columns has no values in first 3 rows and first 8 columns has empty values in second 3 rows.

1

Hi,

i will work if both structure's or same.For different structure just try like this,

if(firstDataTable.Rows.Count > 0)
{
   //Add all Coulmns and values to 3rd datatable.
   
}

In that same way Add second datatable to third.

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

0

Hello there

If i understand u correctly, u need a Nested/group dataset in a single dataset

Do the following, i have created an eg for you.
follow the steps
1) In solution explorer Add-> new Items -> Select "XML Schema"
2) Give the name eg : CommonDS Set
3) Go to the properities of "CommonDS" and Change Custom tool Property: MsDataSetGenerator
4) Right Click CommonDS -> View Code
5) Paste the following code Then change the Table NAme & Column names as per your requirement.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="CommonDS" targetNamespace="http://tempuri.org/CommonDS.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/CommonDS.xsd" xmlns:mstns="http://tempuri.org/CommonDS.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="CommonDS">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Table1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Col1" type="xs:string" />
              <xs:element name="Col2" type="xs:int" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
       
        <xs:element name="Table2">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Column1" type="xs:string" />
              <xs:element name="Column2" type="xs:int" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Pls. Mark as solved if it helps you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.