Note: This scenario is intended for use by ASP to connect all types of databases through their own development components
Some enterprise databases now use Informix, and most developers have fewer operations on the database,
Because the current company has been eaten by IBM, and IBM main push is its DB2, not many
Using the OLE DB component, the connection is established through Server.CreateObject ("adodb.connection"), even
Can be successful, but the speed is full of panic, especially the number of data bar more than 20,000 of the table, even if only
is a query, and almost not out, the entire ASP host the efficiency of plummeting, memory consumption increased. Right
To this issue, I used Delphi to write a simple component.
The main code is as follows:
Unit main;
{$WARN Symbol_platform off}
Interface
Uses
ActiveX, Mtsobj, Mtx, Comobj, Aspbde_tlb, stdvcl,db,dbtables,sysutils;
Type
Tbdeasp = Class (Tmtsautoobject, ibdeasp)
Protected
function open (const SQLSTR, aliname:widestring): olevariant;
Safecall;
function execute (const SQLSTR, connstr:widestring): olevariant;
Safecall;
{Protected declarations}
End
Implementation
Uses Comserv;
function Tbdeasp.open (const SQLSTR, aliname:widestring): olevariant;
Var
Tmpre:variant;
Begin
Tmpre:=createoleobject (' Adodb.recordset ');
Try
Tmpre.open (Sqlstr,aliname);
Except
End
Result:=tmpre;
End
function Tbdeasp.execute (const SQLSTR, connstr:widestring): olevariant;
Var
Tmpre:variant;
Begin
Tmpre:=createoleobject (' adodb.connection ');
Try
Tmpre.open (CONNSTR);
Tmpre.execute (SQLSTR);
Result:=1;
Except
result:=0;
End
End
Initialization
Tautoobjectfactory.create (COMServer, tbdeasp, class_bdeasp,
Cimultiinstance, Tmboth);
End.
This program only wrote the simplest two methods Open,execute, you can add according to their own needs
Other methods, attributes, and so on.
The method is invoked as follows:
Ser var=server.createobject ("appname.bdeasp")
Set Rs=var.open ("SQL statement", "database connection statement")
Rs use method and Adodb.recordset objects exactly the same, after testing, speed significantly accelerated!!! System
Consume a lot of drop, 20 million data table, query speed very quickly.