ASP Lecture 4 Installable Components - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

ASP Lecture 4 Installable Components

Description:

Ad Rotator, Content Linking, Content Rotator, Counters, File Access, Page ... ADODB.Connection: to a data provider (db) ... ADODB.Field: a component in a recordset ... – PowerPoint PPT presentation

Number of Views:68
Avg rating:3.0/5.0
Slides: 9
Provided by: aurora5
Category:

less

Transcript and Presenter's Notes

Title: ASP Lecture 4 Installable Components


1
ASP Lecture 4Installable Components
  • Collaboration Data Objects CDONTS
  • Supported messaging (email)
  • ActiveX Data Objects ADODB
  • A COM interface to databases and other sources.
  • Others
  • Ad Rotator, Content Linking, Content Rotator,
    Counters, File Access, Page Counter, Permission
    Checker

2
ADO Active Data Objects
  • ADODB.Connection to a data provider (db)
  • ADODB.Recordset the records returned from a
    query (or a whole table)
  • ADODB.Field a component in a recordset
  • ADODB.Command an SQL statement that returns a
    recordset
  • ADODB.Parameter holds parameters in an SQL
    statement
  • ADODB.Error, ADODB.Property

3
Connection object
  • A connection to the database. Can be used for
    more than one query.
  • Properties
  • ConectionTimeout
  • CommandTimeout
  • ConnectionString
  • Methods
  • Open
  • Close

4
Creating a connection object(http//www.asp101.co
m/samples/database.asp)
  • Set DataConn Server.CreateObject("ADODB.Connecti
    on")
  • DataConn.ConnectionTimeout 15 'property
  • DataConn.CommandTimeout 30 property
  • Note, this has no connection to any data yet.
  • DataConn.Open "DBQ" Server.MapPath("database.md
    b") "DriverMicrosoft Access Driver (.mdb)
    DriverId25 MaxBufferSize8192 Threads20",
    "username", "password"
  • An Access database, database.mdb on the default
  • directory. Fill in correct username and
    password

5
Recordset object
  • Records in a query or table from the connection
  • It must be opened to have anything in it
  • Properties
  • ActiveConnection the current data source
  • Fields in the table
  • BOF, EOF of the recordset
  • Methods
  • AddNew
  • Delete
  • MoveFirst, MoveNext, MoveLast
  • Open, Close

6
Command object
  • Not necessary (one can just type in when a
    recordset is opened), but a neat way to define
    and reuse commands
  • Properties
  • CommandText
  • CommandType (adcmdText SQL, adcmdTable table
    name,
  • Methods
  • Execute

7
Example (http//www.asp101.com/samples/database.as
p)
  • Set cmdDC Server.CreateObject("ADODB.Command")
  • cmdDC.ActiveConnection DataConn
  • cmdDC.CommandText "SELECT FROM sample WHERE
    (Sales " strLTorGT " " iCriteria ") ORDER
    BY " strSortBy strOrder ""
  • cmdDC.CommandType 1
  • Set rsDC Server.CreateObject("ADODB.Recordset")
  • rsDC.Open cmdDC, , 0, 1
  • ' Open record set with a forward-only cursor ( 0)
    in read-only mode (1)
  • Note, we could have typed in the command
  • Review rest of the example

8
File Access
  • Access to a file system via the FileSystemObject
  • Server.CreateObject(Scripting.FileSystemObject)
  • File system has folders, drives, files
  • Methods CreateFolder, CreateTextFile,
    DriveExists, DeleteFile, GetFile, OpenTextFile,
    ...
  • Text file methods Read, ReadLine, Write,
  • Examples
  • http//www.asp101.com/samples/counter.asp
  • http//www.asp101.com/samples/modified.asp
  • http//www.asp101.com/samples/textfile.asp
Write a Comment
User Comments (0)
About PowerShow.com