How to display result from two different table

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default How to display result from two different table

    Hi all

    Iam in a problem. Anyone plz help me in retreving data into single
    datagrid from two different queries.


    Thanks in adavance

    vasu


    vasu Guest

  2. Similar Questions and Discussions

    1. Get result from temporary Oracle Table
      Hi, Having problem with temporary table from Oracle. Runing my stored procedure (which stores an amount of row in a temporary table) from an Sql...
    2. order table result without reloading
      I've a page wich show the result of a query in a table. I want to provide a way to order the way the result are shown, something like: <table>...
    3. [PHP] How to store result in array for later display?
      In the following code snippet, I populate an array called $emp_final, which works fine, as I can tell if I uncomment the echo immediately after. If...
    4. Efficient way to display a dropdown description value when only the key is in the result set
      Hi all, I have a results set with a column ( project_id ) which is associated with a dropdown in datagrid edit mode. When not in edit mode, I...
    5. Result of Mysql Query in a PHP table
      Hi, I've a problem: I want to have the result of my Mysql Query in a Table in my php file. Now I've this: <?
  3. #2

    Default Re: How to display result from two different table

    The problem is that binding can only occur on a single datasource. You will
    need to take these two datasets which you get returned from the two
    different queries and merge them into one dataset then bind to this
    aggregate dataset. You may be able to use the merge function exposed by the
    dataset or you may want to create a new dataset, attach a new table to it
    and manually add rows from both datasets into this one datatable. once you
    are done, you can bind to this new dataset. Either approach should bring you
    the required results.

    Here is some code to help you with the lata if you choose to go thru it

    DataSet dsTemp = new DataSet();

    DataTable Tables = new DataTable();

    dsTemp.Tables.Add(Tables);

    dsTemp.Tables[0].Columns.Add( " ", System.Type.GetType( "System.String" ) );

    dsTemp.Tables[0].Columns.Add( "% variance", System.Type.GetType(
    "System.String" ) );



    for(int col = 0; col < ds.Tables[0].Columns.Count; col++)

    {

    DataRow myRow = dsTemp.Tables[0].NewRow();

    myRow[2]= Double.Parse(ds.Tables[0].Rows[0][col].ToString()) -
    Double.Parse(ds2.Tables[0].Rows[0][col].ToString());

    myRow[1]= (Double.Parse(myRow[2].ToString()) /
    Double.Parse(ds2.Tables[0].Rows[0][col].ToString())) * 100;

    myRow[0]= ds.Tables[0].Columns[col].ColumnName;


    dsTemp.Tables[0].Rows.Add(myRow);



    This will point you down the right direction.

    Regards
    --


    -----------
    Got TidBits?
    Get it here: [url]www.networkip.net/tidbits[/url]
    "vasu" <vasu@stcroixsystems.com> wrote in message
    news:uCwtNf0rDHA.2224@TK2MSFTNGP09.phx.gbl...
    > Hi all
    >
    > Iam in a problem. Anyone plz help me in retreving data into single
    > datagrid from two different queries.
    >
    >
    > Thanks in adavance
    >
    > vasu
    >
    >

    Alvin Bruney Guest

  4. #3

    Default Re: How to display result from two different table

    "vasu" <vasu@stcroixsystems.com> wrote in message news:<uCwtNf0rDHA.2224@TK2MSFTNGP09.phx.gbl>...
    > Hi all
    >
    > Iam in a problem. Anyone plz help me in retreving data into single
    > datagrid from two different queries.
    >
    >
    > Thanks in adavance
    >
    > vasu
    Is it possible to join the two queries into one? Use an "Inner Join".
    If two seperate tables have a like column in each that can link to
    each other, then you can use that like value to create a join of the
    two tables. For example, if you are pulling "names" from one table in
    your first query, and then "locations" from another table in your
    second query, would you somehow be able to join the two tables on a
    like value and run one query to create one dataset? Let's say that
    each table has a column named "IDNumber" that represents a unique
    number for a certain person on both tables. Example:

    SELECT
    Names.Firstname,
    Names.LastName,
    Locations.PrimaryOffice,
    Locations.AlternateOffice
    FROM
    Names INNER JOIN Locations ON Names.IDNumber = Locations.IDNumber
    order by Names.LastName

    Then all you would need to do is set the source and bind that single
    dataset to the control.
    Todd Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139