Retrieve the Multiple Tables in Gridview [Resolved]

Posted by Siri under ASP.NET on 3/29/2012 | Points: 10 | Views : 2329 | Status : [Member] | Replies : 2
How to Retrieve the Multiple Tables on Gridview.




Responses

Posted by: Self-Innovator on: 3/30/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi try this
Create the SP Which returns Multiple table values
CREATE PROCEDURE [dbo].[spGetMultipleValues]

@RefNumber INT
AS
BEGIN
IF EXISTS(SELECT RefNumber FROM dbo.tbFSMain WHERE RefNumber=@RefNumber)
SELECT FS.oldCompanyName FROM dbo.tbFSSupDtls FS WHERE RefNumber=@RefNumber
SELECT DesignName FROM dbo.tbFSContact WHERE RefNumber=@RefNumber
SELECT ID,ShareholderName FROM dbo.tbFSOwnership WHERE RefNumber=@RefNumber
END



Call this Sp from Front End
EX:-
objDS = objPmssrch.fnFSGetCompanyDetails(strRefnumber) //Exec the Sp in This Function

If objDS.Tables.Count > 0 Then
If objDS.Tables(0).Rows.Count > 0 Then
// Do your operations here like
objDs.Tables(0).Rows(0).Item("oldCompanyName")
End If
If objDS.Tables(1).Rows.Count > 0 Then
// Do your operations here like
objDs.Tables(1).Rows(0).Item("DesigCategory")
End If

End If


Join Hands Change lives
Thanks & Regards
Straight Edge Society

Siri, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/29/2012 [Member] Silver | Points: 25

Up
0
Down

1)By joining bring data from multiple tables and then bind it to the gridview
2) if you want view data of two table having similar structure ,column-wise:
then write like select col1,col2,col3 from t1
union select col1,col2,col3 from t2

Then bind the resultset to gridview.

Thanks,
Sanjay

Siri, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response