The primary tutorial wrote seven, and there is certain that some primary things need to be written, I will slowly add
Intermediate tutorial content:
This may also be the most concerned: such as: the operation and package of the database. The use of an ASP built-in object. I will spend longer, this part of this part requires you to be more skilled using ADO operational database and is more familiar with the 5 objects of ASP.
Let's take a look at some information about online comparison:
As we all know, the ASP has built-in Response, Request, Server, Session, Application five objects. In fact, these five built-in objects are the five ActiveX DLL components initialized in IIS console. Since IIS can initialize these five components in ASP, We can certainly reference these components directly in our ActiveX DLL to implement our programming, that is, we can implement the function of accessing the ASP built-in object by reference to these components in the VB application. As long as you have a web server above PWS4 or IIS4, you have a name called "Microsoft Active Server Pages Object", we can reference this object library in the VB's ActiveX DLL application, by reference to this object library, We have gained an object (class): ScriptingContext, this object is also the core object of our entire article. The relationship within the object library is as follows: Object Library Class Class members ASPTYPELIBRARY ScriptingContext Application Request Response Session Server Through the above diagram, we can easily understand the class scriptingcontent.
Let's take a concrete example:
Open VB6, create a new ActiveX DLL project. The engineering name is modified to FCOM and the class name is modified to FZ1 reference "Microsoft Active Server Pages Object" object library. Create two component events: OnStartPage and OneundPage Create a reference to the class ScriptingContent in the event onstartpage. Instantiated class scriptingcontent.
The code is as follows: Option Explicit
'Statement of the object
DIM MyResponse as response
DIM MyRequest as Request
DIM MyApplication AS Application
DIM MyServer As Server
DIM MySession as session
'When the component is created, this event will be triggered.
Public Sub onstartPage (MyScriptingContent as scriptingcontext)
'Instantiation of objects
Set myresponse = myscriptingContent.response
Set myRequest = myscriptingcontent.request
Set myserver = myscriptingContent.server
SET myApplication = myscriptingcontent.application
Set mysession = myscriptingContent.Session
MyResponse.write "ActiveX DLL components have been created!"
End Sub
'Trigger this event when the component is destroyed
Public Sub OneendPage () MyResponse.write "ActiveX DLL component has been destroyed!"
'Destroying object
Set myresponse = Nothing
Set myRequest = Nothing
Set myserver = Nothing
Set myapplication = Nothing
Set mysession = Nothing
End Sub
'Define our own component method
Public Sub HelloWorld ()
MyResponse.write "This is written with ASP built-in object"
End Sub
test
Open Visual InterDev6.0 to generate an ASP file
<% @ Language = VBScript%>
<%
Set obj = server.createObject ("fcom.fz1")
Call obj.helloworld ()
%>
Body>
Html>
Configure a virtual directory, perform this ASP file in IE, resulting in the following:
The ActiveX DLL component has been created! This is the ActiveX DLL component written by the ASP built-in object has been destroyed!