I have been busy this time, huh, huh
Today, let's take a look at a complete data package, with a paging example
Open VB6, create a new ActiveX DLL project. The engineering name is modified to FCOM, and the class name is modified to FZ8 reference "Microsoft Active Server Pages Object", "Microsoft ActiveX Data Object 2.7 Library" object library.
Create two component events: OnStartPage and OneundPage Create a reference to the class ScriptingContent in the event onstartpage. Instantiated class scriptingcontent.
code show as below:
Option expedition
'********************************************************** *
'Author: Tornado
'Features: Simple and fully packaged components
'time:
2005-01-01
'********************************************************** *
'Statement of the object
DIM MyResponse as response
DIM MyRequest as Request
DIM MyApplication AS Application
DIM MyServer As Server
DIM MySession as session
'Private variable
PRIVATE MPAGESIZE AS Long
Private mstrsql as string
'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
End Sub
'Trigger this event when the component is destroyed
Public Sub OneendPage ()
'Destroying object
Set myresponse = Nothing
Set myRequest = Nothing
Set myserver = Nothing
Set myapplication = Nothing
Set mysession = Nothing
End Sub
'Display Table
Public function showtable ()
DIM CONN As New Adodb.connection
DIM RS As New Adodb.Recordset
DIM I as integer
DIM J AS INTEGER
DIM INTPAGE AS INTEGER
DIM INTPAGECUNT AS INTEGER
DIM STRScriptName As String
DIM INTPOS AS INTEGER
DIM INTFIELDCOUNT AS INTEGER
'Get the path
strscriptname = myRequest.serverVariables ("script_name")
INTPOS = INSTRREV (strscriptname, "/")
IF INTPOS <> 0 THEN
STRSCRIPTNAME = MID (strscriptname, INTPOS 1) Endiff
IF ISempty (MyRequest ("Page")).
INTPAGE = 1
Else
INTPAGE = CINT (MyRequest ("Page"))
END IF
ON Error Goto ERR
Conn.open "provider = SQLOLEDB.1; PERSIST security info = false; user ID = sa; initial catalog = northwind; data source = localhost"
RS.Open MSTRSQL, CONN, AdopenStatic, AdlockReadonly
'Get the number of records
INTFIELDCOUNT = rs.fields.count
'Output form
MyResponse.write "
" & RS (i) .Name & " TH>"
NEXT MyResponse.write " TR>" 'Output content For i = 1 to Mpagesize IF r.eof then EXIT for END IF MyResponse.write " |
---|
" & rs.fields (j) .Value & " TD>"
NEXT MyResponse.write " TR>" rs.movenext NEXT 'Output paging MyResponse.write " |