Develop ASP paging components with Delphi

Source: Internet
Author: User
Tags integer
Paging due to Delphi in the development of database application system has a strong function and very high efficiency, so the author of the development of ASP components more commonly used is Delphi 5.0 (of course, can also use Visual Basic or VC + + development of ASP components), Delphi itself has a number of components in the Internet and internetexpress two palette that can generate Web pages directly, but these components are missing the page's common paging functionality. As we all know, ASP is to create a Recordset object after the creation of ADO connection database, and then use the AbsolutePage of the recordset for page positioning, and in Delphi 5.0, has provided the ADO component encapsulates the Microsoft ADO Library, So it also has the page positioning function. Here's a step-by-step way to develop a generic ASP component that displays a paging Web page.

Step One: Create an ActiveX Library, name it padopage, and then create a new active Server Object Class, named Adopage, to create an ASP component called Adopage. The file is named Adopage.pas.

Step Two: Open the Type Library, create a new method Get_page, and then add a parameter Pconnandsgl to the Get_page, which is used to pass the database connection statement and the SQL statement, with the parameter selected as the BSTR type.

Step three: Create a new datamodule, put the adoconnection component and the Adoquery component, and name the data module Adodatamodule. Because the method in the newly established component Get_page to get the data from the Datamodule, you need to add adodatamodule to the ADOPAGE.PAS uses clause and declare the variable FADODM of a data module. Add both Initialize and Destroy methods to generate data modules in ASP group. The Adopage.pas specific code looks like this:

Unit adopage;

Interface

Uses

Comobj, Sysutils, Classes, ActiveX, Asptlb, Pbasedata_tlb, STDVCL, Adodatamodule;

Add Adodatamodule to the USE clause

Type

T adopage = Class (Taspobject, Ibasedata)

Private

Fadodm:tadodatamoduleform;

Protected

Procedure OnEndPage; Safecall;

Procedure OnStartPage (const ascriptingcontext:iunknown); Safecall;

Procedure Get_page (const pconnandsql:widestring); Safecall;

Public

Procedure Initialize;override;

destructor Destroy;override;

End

Implementation

Uses comserv,forms;

destructor Tadopage.destroy;

Begin

inherited;

FADODM. Destroy;

End

Procedure Tadopage.initialize;

Begin

inherited;

Fadodm:=tadodmform. Create (forms.application);

End

Fourth step: To establish a common method of paging display data get_page, the specific code is as follows:

Procedure Tadopage.get_page (const pconnandsql:widestring);

var I,j,n:integer;

connstr,sqlstr:widestring;

Rs:_recordset;

cur_url:widestring;

Page_no:integer;

Begin

First, remove the connection string and the SQL statement from the parameters passed.

Pconnandsql:=uppercase (Pconnandsql);

I:=pos (' ConnStr ', pconnandsql);

J:=pos (' Sqlstr ', pconnandsql);

If i=0 or j=0 then

Begin

Response.Write (' database connection string or SQL statement error! ');

Abort



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.