ASP Lecture 5: More ADODB - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

ASP Lecture 5: More ADODB

Description:

Allows multiple recordsets without recreating and duplicating the connection ... Ref: Shelly Powers. Open VB. Select File/New Project/ActiveX DLL ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 7
Provided by: aurora5
Category:
Tags: adodb | asp | lecture | more | shelly

less

Transcript and Presenter's Notes

Title: ASP Lecture 5: More ADODB


1
ASP Lecture 5 More ADODB
  • Major objects Connection and Recordset
  • Possible interfaces to a database
  • via a connection (last lecture)
  • directly (this week)

Recordset
Connection
DB
Recordset
Recordset
2
Comparison
  • Connection
  • Cleaner
  • Allows multiple recordsets without recreating and
    duplicating the connection
  • Easier to change in one place
  • Just recordset
  • Less code to write (not a good reason)

3
Using a connection
  • Set DataConn Server.CreateObject("ADODB.Connecti
    on")
  • strConnString "DRIVERMicrosoft Access Driver
    ...
  • DataConn.Open strConnString, strUserId, strPasswd
  • Set rsObj Server.CreateObject("ADODB.Recordset")
  • cmdSQL SELECT
  • rsObj.Open cmdSQL, DataConn, CursorType,
    LockType,..
  • The first param is an SQL statement, a table,
    procedure name
  • The second param is a connection object or string
    with connection text

4
Using a recordset
  • With intermediate variables
  • strConnString "DRIVERMicrosoft
    Access...
  • Set rsObj Server.CreateObject("ADODB.Record
    set")
  • rsObj.Open cmdSQL, strConnString,
  • More confusing, put everything in the Open
    command
  • rsObj.Open SELECT, "DRIVERMicrosoft
    Access,
  • Examples of adding, deleting, updating an
    element .../samples/db_add.asp
    /samples/db_del.asp, .../samples/db_update.asp

5
ASP Components
  • Components (e.g. ADODB) have classes
  • e.g. Connection, Recordset, Field, Command,..
  • Classes have methods
  • e.g. Open, Close,..
  • The ADODB.dll is available to ASP pages and
    supports this component
  • An object is created in an ASP page with the
    create method of Server
  • Server.CreateObject(component_name.class_name)
  • objDataConn Server.CreateObject(ADODB.Connection
    )
  • The object then has access to the methods of the
    class.

6
Developing components
  • Most easily built in VB. Ref Shelly Powers.
  • Open VB
  • Select File/New Project/ActiveX DLL
  • You get Project1 and a Class1 window
  • Change Project1 name to Wells in
    Project/Properties
  • Change Class1 name to CLA in the window for Class
    1
  • Build functions for AddNew, Remove, in the
    (Code) window
  • Public Function AddNew()
  • ...
  • End Function
  • Make/Project creates Wells.dll
  • regsvr32 Wells.dll registers it
  • objCLA Server.CreateObject(Wells.CLA) creates
    an instance
Write a Comment
User Comments (0)
About PowerShow.com