Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i hv made a stored procedure in MSsql 2005 which contains four select statments for retriving data from four different tables. now i m using the stored procedure in my web application (asp.net with c#). how can i get access to data in the form of different tables retrived by the procedure if i have to pass them as datasource to four different datalists. Please Suggest something ,so that i have not to made four different procedures for four different select statements and the data fetched by single procedure can be easily bind to four different datalists simultaneously.
Thanx


stored procedure is:

SQL
ALTER PROCEDURE [dbo].[sp_select_interest]
    -- Add the parameters for the stored procedure here
    ( @uid int
)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    select music_liked.uid,music_liked.music_id,music.music_pic from music_liked,music where music_liked.music_id = music.music_id and music_liked.uid = @uid
    select movies_liked.uid,movies_liked.movies_id,movies.movies_pic from movies_liked,movies where movies_liked.movies_id = movies.movies_id and movies_liked.uid = @uid
    select books_liked.uid,books_liked.books_id,books.books_pic from books_liked,books where books_liked.books_id = books.books_id and books_liked.uid = @uid
    select games_liked.uid, games_liked.games_id, games.game from games_liked,games where games_liked.games_id = games.games_id and games_liked.uid = @uid
END
Posted
Updated 24-Apr-11 3:34am
v2

 
Share this answer
 
SQL
ALTER PROCEDURE [dbo].[sp_select_interest]
    -- Add the parameters for the stored procedure here
    ( @uid int,
      @Type varchar

)
AS
BEGIN
    
if @Type = 'Music'
begin
    select music_liked.uid,music_liked.music_id,music.music_pic from music_liked,music where music_liked.music_id = music.music_id and music_liked.uid = @uid
end
If @Type = 'Movies'
begin
    select movies_liked.uid,movies_liked.movies_id,movies.movies_pic from movies_liked,movies where movies_liked.movies_id = movies.movies_id and movies_liked.uid = @uid
end

if @Type = 'Books'
begin
    select books_liked.uid,books_liked.books_id,books.books_pic from books_liked,books where books_liked.books_id = books.books_id and books_liked.uid = @uid
end
.  
.
END
 
Share this answer
 
Comments
shikha_14 24-Apr-11 9:31am    
Thanx. But that is helpful if i want to bind data according to some selection. like if someone has selected one type and accordingly the procedure will fetch the data from tables. but i want to show all the four select statements to work togather and the data retrived by procedure is then bind with four different datalists simultaneously. Please Suggest something for that. so that i have not to made four different procedures for four different select statements and the data fetched can be easily bind to four different datalists simultaneously not on any selection. Thanx.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900