Delphi控件里拉一个TADOStoredProc,配置好相关链系,具体的操作列子如下:
1 procedure TForm1.btnFirstClick(Sender: TObject); 2 begin 3 4 sp1.Close; 5 sp1.Parameters.Clear; 6 sp1.ProcedureName:= 'Proc_SplitPage2'; 7 8 sp1.Parameters.CreateParameter('tblName',ftString,pdInput,20,fgUnassigned); 9 sp1.Parameters.CreateParameter('strFields',ftString,pdInput,20,fgUnassigned); 10 sp1.Parameters.CreateParameter('strOrders',ftString,pdInput,20,fgUnassigned); 11 sp1.Parameters.CreateParameter('strOrderType',ftString,pdInput,20,fgUnassigned); 12 sp1.Parameters.CreateParameter('PageSize',ftInteger,pdInput,4,fgUnassigned); 13 sp1.Parameters.CreateParameter('PageIndex',ftString,pdInput,20,fgUnassigned); 14 sp1.Parameters.CreateParameter('strWhere',ftString,pdInput,20,fgUnassigned); 15 16 // exec [Proc_SplitPage2] 'NewsInfo','*','ID','ASC',10,3,'' 17 sp1.Parameters[0].Value := 'NewsInfo'; 18 sp1.Parameters[1].Value := '*'; 19 sp1.Parameters[2].Value := 'ID'; 20 sp1.Parameters[3].Value := 'DESC'; 21 sp1.Parameters[4].Value := 10; 22 sp1.Parameters[5].Value := 1; 23 sp1.Parameters[6].Value := ''; 24 25 sp1.ExecProc; 26 sp1.Open; 27 28 end; 29 30 procedure TForm1.FormShow(Sender: TObject); 31 begin 32 pageIndex := 1; 33 end; 34 35 procedure TForm1.btnPreClick(Sender: TObject); 36 begin 37 38 sp1.Close; 39 sp1.Parameters.Clear; 40 sp1.ProcedureName:= 'Proc_SplitPage2'; 41 42 sp1.Parameters.CreateParameter('tblName',ftString,pdInput,20,fgUnassigned); 43 sp1.Parameters.CreateParameter('strFields',ftString,pdInput,20,fgUnassigned); 44 sp1.Parameters.CreateParameter('strOrders',ftString,pdInput,20,fgUnassigned); 45 sp1.Parameters.CreateParameter('strOrderType',ftString,pdInput,20,fgUnassigned); 46 sp1.Parameters.CreateParameter('PageSize',ftString,pdInput,20,fgUnassigned); 47 sp1.Parameters.CreateParameter('PageIndex',ftString,pdInput,20,fgUnassigned); 48 sp1.Parameters.CreateParameter('strWhere',ftString,pdInput,20,fgUnassigned); 49 50 // exec [Proc_SplitPage] 'NewsInfo','*','ID','DESC','10','1','' 51 sp1.Parameters[0].Value := 'NewsInfo'; 52 sp1.Parameters[1].Value := '*'; 53 sp1.Parameters[2].Value := 'ID'; 54 sp1.Parameters[3].Value := 'ASC'; 55 sp1.Parameters[4].Value := '10'; 56 pageIndex := pageIndex - 1; 57 sp1.Parameters[5].Value := pageIndex; 58 sp1.Parameters[6].Value := ''; 59 60 sp1.ExecProc; 61 sp1.Open; 62 end; 63 64 procedure TForm1.btnNextClick(Sender: TObject); 65 begin 66 67 sp1.Close; 68 sp1.Parameters.Clear; 69 sp1.ProcedureName:= 'Proc_SplitPage2'; 70 sp1.Parameters.CreateParameter('tblName',ftString,pdInput,20,fgUnassigned); 71 sp1.Parameters.CreateParameter('strFields',ftString,pdInput,20,fgUnassigned); 72 sp1.Parameters.CreateParameter('strOrders',ftString,pdInput,20,fgUnassigned); 73 sp1.Parameters.CreateParameter('strOrderType',ftString,pdInput,20,fgUnassigned); 74 sp1.Parameters.CreateParameter('PageSize',ftString,pdInput,20,fgUnassigned); 75 sp1.Parameters.CreateParameter('PageIndex',ftString,pdInput,20,fgUnassigned); 76 sp1.Parameters.CreateParameter('strWhere',ftString,pdInput,20,fgUnassigned); 77 78 sp1.Parameters[0].Value := 'NewsInfo'; 79 sp1.Parameters[1].Value := '*'; 80 sp1.Parameters[2].Value := 'ID'; 81 sp1.Parameters[3].Value := 'ASC'; 82 sp1.Parameters[4].Value := '10'; 83 pageIndex := pageIndex + 1; 84 sp1.Parameters[5].Value := pageIndex; 85 sp1.Parameters[6].Value := ''; 86 87 sp1.ExecProc; 88 sp1.Open; 89 end;