Hello All
Thank you for any help you can provide!
I have a long list of links with decscriptions titles etc in a SQL Server
2000 database. The basic problem is that I am attempting to use a data base
cursor to to the proper starting point in a sorted view, get the next 10-or
20 records and return them. Problem is ony one record is being returned.
Here is the code
SQL
ALTER PROCEDURE dbo.PS_GetLinks
@start as int, @rcount as int
AS
declare @ACounter as tinyint
declare @RecordCount as tinyint
set @ACounter=1
set @RecordCount = (Select Count (id) FROM Selectlinks)
Declare My_Cursor CURSOR SCROLL for SELECT URL, Title, description,
@RecordCount as Rcnt
FROM Selectlinks
Open My_Cursor
Fetch absolute @start FROm My_Cursor
WHILE (@ACounter < @rcount)
BEGIN
fetch next FROM My_Cursor
set @ACounter = @ACounter + 1
END
Close My_Cusor
Deallocate my_Cursor
RETURN
--ASP NET code below
Dim Start As Int64 = 1 '(mPage * (10 - 9))
Dim rd As SqlClient.SqlDataReader
Dim cmd As SqlClient.SqlCommand = con.CreateCommand
Dim lnk As HyperLink
Try
cmd.Parameters.Add("@start", 1)
cmd.Parameters.Add("@rcount", 10)
cmd.CommandText = "PS_GetLinks"
cmd.CommandType = CommandType.StoredProcedure
con.Open()
rd = cmd.ExecuteReader
While rd.Read
lnk = New HyperLink
lnk.NavigateUrl = rd("URL").ToString
lnk.Text = rd("title")
centercontent.Controls.Add(lnk)
centercontent.Controls.Add(New LiteralControl("<br>"))
'RecordCount = rd("rcnt")
End While
Dim nav As New MultiPage(mPage, 10, 340)
centercontent.Controls.AddAt(0, nav.buildnav)
'Catch ex As Exception
Finally
If Not rd Is Nothing Then
rd.Close()
End If
If Not con Is Nothing Then
con.Close()
End If
End Try
Mary Chipman [MSFT] - 30 May 2005 17:38 GMT
So why are you using a cursor instead of a SELECT statement with a
WHERE clause?
--Mary
>Hello All
>Thank you for any help you can provide!
[quoted text clipped - 97 lines]
>
>End Try