Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > How to display result from two different table

Reply
Thread Tools

How to display result from two different table

 
 
vasu
Guest
Posts: n/a
 
      11-20-2003
Hi all

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


Thanks in adavance

vasu


 
Reply With Quote
 
 
 
 
Alvin Bruney
Guest
Posts: n/a
 
      11-21-2003
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: www.networkip.net/tidbits
"vasu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all
>
> Iam in a problem. Anyone plz help me in retreving data into single
> datagrid from two different queries.
>
>
> Thanks in adavance
>
> vasu
>
>



 
Reply With Quote
 
 
 
 
Todd
Guest
Posts: n/a
 
      11-24-2003
"vasu" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
running same script on same data on two different machines -->different result Christopher Brewster Python 5 11-14-2008 08:19 PM
Zlib::GzipWriter - same code - different OS - different result. denmat Ruby 2 04-23-2008 06:45 AM
why get different result of a simple code on different compiler? Tao Wang C++ 4 11-09-2005 01:29 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM



Advertisments