With the development of network technology and the popularity of Internet, Browser / Server has become mainstream in software development, and the author uses the B / S software mode when developing an ERP system, and the specific architecture is the SQL Server Iis IE page is Active. Server page file. Since the system involves a large number of data operations and queries, if the proportion of the ASP scripting language is necessary to cause low efficiency, in order to improve the overall efficiency and security of the system, the author uses the ASP component to replace the ASP scripting language. Since Delphi has strong features and extreme efficiency in the development database application, the author develops ASP components more commonly used to delphi 5.0 (of course, Visual Basic or VC development ASP components), Delphi itself is in Internet and InternetExpress Two component panels provide a number of components that can directly generate a web page, but these components are missing from data displaying common paging features in web pages. As we all know, the ASP is to establish a Recordset object by establishing an ADO connection database, and then utilizes the Recordset's ABSOLUTEPAGE page location, and in Delphi 5.0, the ADO component has been provided to encapsulate Microsoft ADO libraries, so there is also a page positioning function. The author will step by step to develop an ASP component of a universal display paging web page. Step 1: New ActiveX Library, named Padopage, then create an Active Server Object Class, named Adopage, which is established as an ASP component named AdoPage, and the file is named Adopage.PAS. Step 2: Open Type Library, create a new method get_page, then join a parameter PCONNADSGL in GET_PAGE, to pass the database connection statement and the SQL statement, the parameter is selected as the BSTR type. Step 3: Create a new DataModule, add the Adoconnection component and AdoQuery components, name the Data Module Adodatamodule. Since the method in the newly established components get data from DataModule, add AdodataModule to the USES clause of AdoPage.PAS, then declare a variable Fadodm of a data module, and join both of Initialize and Destroy, so that A data module is generated in the ASP group.
Adopage.pas specific code as follows: unit Adopage; interface uses ComObj, SysUtils, Classes, ActiveX, AspTlb, Pbasedata_TLB, StdVcl, AdoDataModule; // Add the AdoDataModule 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: establishing a common paging method for displaying data get_page, specific code 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, from the passed Remove the connection string and SQL statement in the parameter 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; end; for n: = i 8 to j-1 do connStr: = connStr PConnandsql [n]; for n: = j 7 to length (pconnandsql) do sqlstr: = SQLSTR PCONNANDSQL [N]; // The acquired connection string and SQL statements are assigned to adoconnection and adoquery fadodm.adoconnection1.connstring: = connStr; fadodm.adoquery1.sql.add (sqlstr); // below is to open the database Make paging process try fadodm.adoquery1.open; // Open Database rs: = fadody.adoQuery1.recordset; // Get the current open page URL and page Try if Request.serverVariable ['url']. Count>
0 then cur_url: = request.servervariable.item [ 'url']; if request.querystring [ 'page_no'] count> 0 then page_no:. = Request.querystring.item [ 'page_no'] else page_no: = 1; except End; rs.pageSize: = 20; // Set to 20 lines of rhythm = Page_no; // Page Location Response.write ('total' INTOSTR (RS.PageCount) 'page &'); response .write ('first' INTOSTR (PAGE_NO) 'page &'); // Build a hyperlink for each page number for i: = 1 to rs.pagecount do response.write (' INTOSTOSTR (i) ' '); // Data Record Press the table Display RESPONSE.WRITE ('