| |

VerySource

 Forgot password?
 Register
Search
View: 711|Reply: 6

Guiqiu call the stored procedure code!

[Copy link]

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-24 09:20:01
| Show all posts |Read mode
ALTER PROCEDURE [dbo]. [PageList]
(
    @PageSize int,-records per page
    @PageIndex int,-the current number of pages, starting at 1
    @Condition varchar (8000),-query conditions, including and, where, must have a condition such as where 2> 1
    @TheTable varchar (8000), --table name
    @SelectField varchar (8000),-the field to be selected
    @OrderBy varchar (8000), --OrderBy, including order
    @TableID varchar (8000) --table primary key
)
AS
begin
declare @Sql varchar (8000)
 
--Return record
set @ Sql = 'select top' + cast (@PageSize as varchar (10)) + '' + @SelectField + 'from' + @TheTable + '' + @Condition + 'and'
    + @TableID + 'not in (select top' + cast ((@ PageSize * (@ PageIndex-1)) as varchar (10)) + '' + @ TableID + 'from' + @TheTable + '' + @Condition
    + '' + @OrderBy + ')' + @OrderBy
exec (@sql)
 
--- return total
set @ Sql = 'select count (' + @TableID + ') from' + @TheTable + '' + @Condition
exec (@sql)
end
Call this stored procedure, and return the recordset and number of records! Weep! !! !! !! !! !! 1
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-22 14:45:01
| Show all posts
You can get the number of records in the program. If the dataset is returned, the number of records is dataset.Tables [0] .Rows.Count
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-2 02:00:01
| Show all posts
I am foolish. Don't know what exactly is the return record you are talking about?

Return Total: select @@ rowcount
exec [dbo]. [PageList] Parameter 1, Parameter 2, Parameter 3, ...
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-2 23:30:01
| Show all posts
OUTPUT parameter
Reply

Use magic Report

0

Threads

15

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-3-3 09:30:01
| Show all posts
SqlCommand cmd = new ...;
cmd.CommandType = SqlCommandType.sProc // The stored procedure can't remember
cmd.Parameters.Add ("@ PageSize", SqlDbType.Integer);
cmd.Parameters [0] = PageSize;
Reply

Use magic Report

0

Threads

31

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-3-4 23:45:02
| Show all posts
As far as the stored procedures above you are concerned,
dataset.tables [0] is the record of the current page you want
dataset.Tables [1] .rows [0] [0] is your total number of records
Reply

Use magic Report

0

Threads

31

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-3-5 08:45:01
| Show all posts
PS: TOP does not seem to be able to handle multi-primary key paging, it is recommended that the landlord use the temporary table paging method
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list