Click here to Skip to main content
15,895,777 members
Home / Discussions / Database
   

Database

 
GeneralProblem with Update ADO record through VBS Pin
IFriendly23-Aug-05 4:20
IFriendly23-Aug-05 4:20 
GeneralT-SQL Problem Pin
WDI23-Aug-05 2:45
WDI23-Aug-05 2:45 
GeneralRe: T-SQL Problem Pin
Colin Angus Mackay23-Aug-05 3:13
Colin Angus Mackay23-Aug-05 3:13 
GeneralRe: T-SQL Problem Pin
WDI23-Aug-05 4:27
WDI23-Aug-05 4:27 
GeneralRe: T-SQL Problem Pin
Colin Angus Mackay23-Aug-05 4:54
Colin Angus Mackay23-Aug-05 4:54 
GeneralRe: T-SQL Problem Pin
Frank Kerrigan23-Aug-05 4:16
Frank Kerrigan23-Aug-05 4:16 
GeneralFiltering and Paging Pin
WDI23-Aug-05 2:11
WDI23-Aug-05 2:11 
GeneralRe: Filtering and Paging Pin
miah alom25-Aug-05 10:40
miah alom25-Aug-05 10:40 
Here is what you can do,

(1) Create this procedure
CREATE PROCEDURE GetDataByPage(
@SqlStr varchar(8000),
@PageSize int,
@CurrentPage int)
AS
DECLARE @FirstRec int, @LastRec int,@dt varchar(10)
BEGIN
-- Initialize variables.
SELECT @FirstRec = (@CurrentPage - 1) * @PageSize
SELECT @LastRec = (@CurrentPage * @PageSize + 1)

SELECT @dt= substring(convert(varchar,rand()),3,10)

-- Create a temp table to hold the current page of data
SELECT @SqlStr = stuff(@SqlStr,charindex(' FROM ',upper(@SqlStr)),6,' INTO tempdb..Paging'+@dt+' FROM ')
EXECUTE (@SqlStr)

-- Add an ID column to count the records
SELECT @SqlStr = 'ALTER TABLE tempdb..Paging'+@dt+' ADD RID numeric(10) IDENTITY PRIMARY KEY'
EXECUTE (@SqlStr)

--Return the total number of records available as an output parameter
SELECT @SqlStr = 'SELECT Count(*) From tempdb..Paging'+@dt
EXECUTE (@SqlStr)

--Select one page of data based on the record numbers above
SELECT @SqlStr = 'SELECT * FROM tempdb..Paging'+@dt+' WHERE RID > '+convert(varchar,@FirstRec)+' and RID < '+convert(varchar,@LastRec)
EXECUTE (@SqlStr)

-- Drop the temporary table
SELECT @SqlStr = 'DROP TABLE tempdb..Paging'+@dt
EXECUTE (@SqlStr)

END

(2) In sp_getFilteredAdvertisement add two more parameters @pageSize, @pageNo
instead of a call to exec(@sql) use

exec GetDataByPage @sql , @pageSize, @pageNo


Hope this helps.
QuestionCannot lock record? Pin
Javolin22-Aug-05 14:30
Javolin22-Aug-05 14:30 
AnswerRe: Cannot lock record? Pin
Christian Graus22-Aug-05 14:33
protectorChristian Graus22-Aug-05 14:33 
Questioninsert text truncated in ADO, not in ODBC? Pin
ir_fuel22-Aug-05 11:06
ir_fuel22-Aug-05 11:06 
AnswerRe: insert text truncated in ADO, not in ODBC? Pin
toxcct22-Aug-05 20:23
toxcct22-Aug-05 20:23 
GeneralRe: insert text truncated in ADO, not in ODBC? Pin
ir_fuel22-Aug-05 22:28
ir_fuel22-Aug-05 22:28 
AnswerRe: insert text truncated in ADO, not in ODBC? Pin
Rob Graham23-Aug-05 2:32
Rob Graham23-Aug-05 2:32 
GeneralAccess tables providing only 65636 rows Pin
softty22-Aug-05 10:07
softty22-Aug-05 10:07 
GeneralRe: Access tables providing only 65636 rows Pin
softty28-Aug-05 7:50
softty28-Aug-05 7:50 
GeneralUPDATE the first n matching records Pin
Luis Alonso Ramos22-Aug-05 5:36
Luis Alonso Ramos22-Aug-05 5:36 
QuestionWhat does .net stand for? Pin
Tuwing.Sabado22-Aug-05 1:40
Tuwing.Sabado22-Aug-05 1:40 
AnswerRe: What does .net stand for? Pin
toxcct22-Aug-05 3:33
toxcct22-Aug-05 3:33 
Generalview Pin
magnifique22-Aug-05 1:12
magnifique22-Aug-05 1:12 
GeneralRe: view Pin
Frank Kerrigan23-Aug-05 0:08
Frank Kerrigan23-Aug-05 0:08 
GeneralRe: view Pin
magnifique23-Aug-05 0:14
magnifique23-Aug-05 0:14 
GeneralRe: view Pin
Frank Kerrigan23-Aug-05 0:37
Frank Kerrigan23-Aug-05 0:37 
GeneralSQL Server Pin
hung_ngole21-Aug-05 18:59
hung_ngole21-Aug-05 18:59 
GeneralRe: SQL Server Pin
Christian Graus21-Aug-05 19:23
protectorChristian Graus21-Aug-05 19:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.