0

im using a stored procedure to load a number of galleries and then photos within the gallery, however when linking them to the listView only the first two photos are returned.

Stored procedure

ALTER PROCEDURE dbo.test

AS

declare @galID int

Declare c Cursor For Select Distinct gallery_id From galleries
Open c

Fetch next From c into @galID

While @@Fetch_Status = 0 Begin
   select top(2) photo_id, photo_name from photos where gallery_id = @galID
   Fetch next From c into @galID
   
End

Close c
Deallocate c

RETURN

result of executing the stored procedure

photo_id    photo_name                 
----------- -------------------------- 
244         208500_1850052766985_1110  
247         260531_2042291492833_1110  
No rows affected.
(2 row(s) returned)
photo_id    photo_name                 
----------- -------------------------- 
279         DSC00281                   
280         DSC00285                   
No rows affected.
(2 row(s) returned)
photo_id    photo_name                 
----------- -------------------------- 
281         Matt relo-MAT       
No rows affected.
(1 row(s) returned)
@RETURN_VALUE = 0
Finished running [dbo].[test].

binding to listview

using (api_gallery_dataDataContext apiPic = new api_gallery_dataDataContext())
            {
                var PhotoResult = from p in apiPic.test()

                                  select new
                                  {
                                      p.photo_id,
                                      p.photo_name
                                  };


                ListView3.DataSource = PhotoResult;             
                ListView3.DataBind(); //bind items to the listview
            }

The stored procedure is executing but not all items are binding to the listview. Anyone have any ideas to why this is?

Edited by barriegrant1: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by barriegrant1
0

Whats Funny. You are selecting just 2 photos using top(2) clause and expecting to select more. use:
select photo_id, photo_name from photos where gallery_id = @galID

0

Whats Funny. You are selecting just 2 photos using top(2) clause and expecting to select more. use:
select photo_id, photo_name from photos where gallery_id = @galID

This is not the issue as the results of executing the stored procedure is executing correctly, its loading the first 2 photos from 3 galleries. the results however are only binding the first 2 photos from the first gallery and everything after this is not binding?

I did try your method but resulted in the same output. Thanks for your response.

Barrie Grant

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.