Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 DISPLAY DATA FROM TWO TABLES AND ADD 3 COLUMNS

Author  Topic 

jadi
Starting Member

20 Posts

Posted - 2009-01-30 : 09:50:09
Hi

I am new to .net

I have two tables
HEADERS
and LINES

I want to display the data(all rows) from that tables in one data grid. Also I want to add 3 columns in there!

Can you guide me throught that.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2009-01-30 : 10:00:16
Create an Stored proc or View to combine those two tables with additional columns and use that view/SP as a data source for your grid.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

jadi
Starting Member

20 Posts

Posted - 2009-01-30 : 10:08:23
Nice suggestion but I have a SP which puts the data from a view into the two tables and now I want to retrive it in the grid. Please can you guide me?

Thanks in Advance
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-01 : 02:28:09
can u post table structures of header and lines
if they have same no of columns use union
r if it is having common col using joins
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-01 : 02:30:14
try like this once
after getting the data from view to tables

select h.col1,h.col2,....(cols of header),l.col1,l.col2 ..... (cols from lines) from
header h
inner join
lines l on h.col1 = l.col1

if same columns (datatype should also match)
select col1,col2,....
from header
union
select col1,col2,....
from lines

write this code in a stored procedure
then call that sp in ur front end (.net) u can have ur resultset

Go to Top of Page
   

- Advertisement -