Li Tianping'sCodeThe built-in paging stored procedure is found in the generator. When the query condition @ strwhere exceeds@ Strtmp varchar (100)The length of @ strwhere is truncated to 100, and the syntax structure is damaged, The red part is the modified Code. The up_getrecordbypageorder stored procedure will also change in the same way.
------------------------------------
-- Purpose: Paging stored procedures (efficient for tables with primary keys)
-- Note:
------------------------------------
Create procedure up_getrecordbypage
@ tblname varchar (255), -- table name
@ fldname varchar (255 ), -- primary key field name
@ pagesize Int = 10, -- page size
@ pageindex Int = 1, -- page number
@ isrecount bit = 0, -- total number of returned records, if the value is not 0,
@ ordertype bit = 0, -- set the sorting type. If the value is not 0, the system returns a descending order.
@ strwhere varchar (1000) = ''-- Query condition (Note: Do not add where)
as
Declare @ strsql varchar (6000) -- subject sentence
Declare @ strtmp varchar (1000) -- Temporary Variable
Declare @ strorder varchar (400) -- sort type
If @ ordertype! = 0
Begin
Set @ strtmp = '<(select min'
Set @ strorder = 'order by ['+ @ fldname +'] desc'
End
Else
Begin
Set @ strtmp = '> (select Max'
Set @ strorder = 'order by ['+ @ fldname +'] ASC'
End
Set @ strsql = 'select top '+ STR (@ pagesize) +' * from ['
+ @ Tblname + '] Where [' + @ fldname + ']' + @ strtmp + '(['
+ @ Fldname + ']) from (select top' + STR (@ PageIndex-1) * @ pagesize) + '['
+ @ Fldname + '] from [' + @ tblname + ']' + @ strorder + ') as tbltmp )'
+ @ Strorder
If @ strwhere! =''
Set @ strsql = 'select top '+ STR (@ pagesize) +' * from ['
+ @ Tblname + '] Where [' + @ fldname + ']' + @ strtmp + '(['
+ @ Fldname + ']) from (select top' + STR (@ PageIndex-1) * @ pagesize) + '['
+ @ Fldname + '] from [' + @ tblname + '] Where' + @ strwhere +''
+ @ Strorder + ') as tbltmp) and' + @ strwhere + ''+ @ strorder
If @ pageindex = 1
Begin
Set @ strtmp =''
If @ strwhere! =''
Set @ strtmp = 'where' + @ strwhere
Set @ strsql = 'select top '+ STR (@ pagesize) +' * from ['
+ @ Tblname + ']' + @ strtmp + ''+ @ strorder
End
If @ isrecount! = 0
Set @ strsql = 'select count (*) as total from ['+ @ tblname +'] '+ 'where' + @ strwhere
Exec (@ strsql)
Go