This article only provides an example, the user must be flexible according to the specific needs. Recommend 9CBS tornado. NET's Blog ASP component example: http://blog.9cbs.net/online/category/9939.aspx launched VB6.0, New -> Active DLL Project. Click "Project" -> Quote, Select "Microsoft Active Server Pages
Object Library "and" Microsoft ActiveX Data Objects 2.1 Library ". Change the name of the class module to DCSS. Name of the project
Change to YYGWY. Save the project file yygwy.vbp and class file dcss.cls. Dcss.cls written in: Private myscriptingcontext As ScriptingContext Private myapplication As Application Private myrequest As Request Private myresponse As Response Private myserver As Server Private mysession As Session
Public Sub onstartpage (passedscriptingcontext As ScriptingContext) Set myscriptingcontext = passedscriptingcontext Set myapplication = myscriptingcontext.Application Set myrequest = myscriptingcontext.Request Set myresponse = myscriptingcontext.Response Set myserver = myscriptingcontext.Server Set mysession = myscriptingcontext.Session End Sub
Public Sub OneendPage () SET myscriptingContext = Nothing set myapplication = Nothing set myrequest = Nothing set myresponse = nothing set myServer = Nothing set mySession = Nothing end SUB
'The above statement is necessary. 'Define two public functions
Public function rsresult (strsql As String) As Recordset Dim mycnn As Connection Dim myset As Recordset Dim strconnstring As String 'strconnstring = "provider = sqloledb.1; password =;" & "user id = sa;" & "initial catalog = vlog ; "&" data source = hpe60; connect timeout = 15 "strconnstring =" driver = {sql server}; server = yang; uid = sa; pwd =; database = dcss " 'mycnn.ConnectionString = strconnstring mycnn.Open strconnstring myset .ActiveConnection = mycnn myset.Open strsql, mycnn, 3, adCmdText Set rsresult = myset End functionPublic function datasource () As Variant datasource = "driver = {sql server}; server = yang; uid = sa; pwd =; database = dcss "End function
Compile the DCSS.DLL file. Register the Regsvr32 path dcss.dll. Open the Global.asa file with Visual InterDev. Of course, you can also use it in other files. Set dcss = server.createObject ("yygwy.dcss") Oconn = dcss.dataasource () Application ("strconn") = Oconn
Call as follows in other pages: set objconn = server.createObject ("adodb.connection" Objconn.open Application ("strconn")