ADO VISUAL BASIC SCRIPT

Todo sobre Apple, Mac e IphoneNoticias sobre apple,mac, osx, iphone,ipad,apple watch, juegos para mac y appletv

 

APENDICE : VBSCRIPT ACTIVEX DATA OBJECT

FUENTE WWW.W3SCHOOLS.COM

Command Object

The ADO Command object is used to execute a single query against adatabase. The query can perform actions like creating, adding,retrieving, deleting or updating records.

If the query is used to retrieve data, the data will be returned as aRecordSet object. This means that the retrieved data can be manipulatedby properties, collections, methods, and events of the Recordset object.

The major feature of the Command object is the ability to use storedqueries and procedures with parameters.

ProgID

set objCommand=Server.CreateObject("ADODB.command")

Properties

Property

Description

ActiveConnection

Sets or returns a definition for a connection if the connection isclosed, or the current Connection object if the connection is open

CommandText

Sets or returns a provider command

CommandTimeout

Sets or returns the number of seconds to wait while attempting to executea command

CommandType

Sets or returns the type of a Command object

Name

Sets or returns the name of a Command object

Prepared

Sets or returns a Boolean value that, if set to True, indicates that thecommand should save a prepared version of the query before the firstexecution

State

Returns a value that describes if the Command object is open, closed,connecting, executing or retrieving data

Methods

Method

Description

Cancel

Cancels an execution of a method

CreateParameter

Creates a new Parameter object

Execute

Executes the query, SQL statement or procedure in the CommandText property

Collections

Collection

Description

Parameters

Contains all the Parameter objects of a Command Object

Properties

Contains all the Property objects of a Command Object

Connection Object

The ADO Connection Object is used to create an open connection to a datasource. Through this connection, you can access and manipulate a database.

If you want to access a database multiple times, you should establish aconnection using the Connection object. You can also make a connection toa database by passing a connection string via a Command or Recordsetobject. However, this type of connection is only good for one specific,single query.

ProgID

set objConnection=Server.CreateObject("ADODB.connection")

Properties

Property

Description

Attributes

Sets or returns the attributes of a Connection object

CommandTimeout

Sets or returns the number of seconds to wait while attempting to executea command

ConnectionString

Sets or returns the details used to create a connection to a data source

ConnectionTimeout

Sets or returns the number of seconds to wait for a connection to open

CursorLocation

Sets or returns the location of the cursor service

DefaultDatabase

Sets or returns the default database name

IsolationLevel

Sets or returns the isolation level

Mode

Sets or returns the provider access permission

Provider

Sets or returns the provider name

State

Returns a value describing if the connection is open or closed

Version

Returns the ADO version number

Methods

Method

Description

BeginTrans

Begins a new transaction

Cancel

Cancels an execution

Close

Closes a connection

CommitTrans

Saves any changes and ends the current transaction

Execute

Executes a query, statement, procedure or provider specific text

Open

Opens a connection

OpenSchema

Returns schema information from the provider about the data source

RollbackTrans

Cancels any changes in the current transaction and ends the transaction

Events

Note: You cannot handle events using VBScript or JScript (only VisualBasic, Visual C++, and Visual J++ languages can handle events).

Event

Description

BeginTransComplete

Triggered after the BeginTrans operation

CommitTransComplete

Triggered after the CommitTrans operation

ConnectComplete

Triggered after a connection starts

Disconnect

Triggered after a connection ends

ExecuteComplete

Triggered after a command has finished executing

InfoMessage

Triggered if a warning occurs during a ConnectionEvent operation

RollbackTransComplete

Triggered after the RollbackTrans operation

WillConnect

Triggered before a connection starts

WillExecute

Triggered before a command is executed

Collections

Collection

Description

Errors

Contains all the Error objects of the Connection object

Properties

Contains all the Property objects of the Connection object

Error Object

The ADO Error object contains details about data access errors that havebeen generated during a single operation.

ADO generates one Error object for each error. Each Error object containsdetails of the specific error, and are stored in the Errors collection.To access the errors, you must refer to a specific connection.

To loop through the Errors collection:

Syntax

objErr.property

Properties

Property

Description

Description

Returns an error description

HelpContext

Returns the context ID of a topic in the Microsoft Windows help system

HelpFile

Returns the full path of the help file in the Microsoft Windows helpsystem

NativeError

Returns an error code from the provider or the data source

Number

Returns a unique number that identifies the error

Source

Returns the name of the object or application that generated the error

SQLState

Returns a 5-character SQL error code

Field Object

The ADO Field object contains information about a column in a Recordsetobject. There is one Field object for each column in the Recordset.

ProgID

set objField=Server.CreateObject("ADODB.field")

Properties

Property

Description

ActualSize

Returns the actual length of a field's value

Attributes

Sets or returns the attributes of a Field object

DefinedSize

Returns the defined size of a field

Name

Sets or returns the name of a Field object

NumericScale

Sets or returns the number of decimal places allowed for numeric valuesin a Field object

OriginalValue

Returns the original value of a field

Precision

Sets or returns the maximum number of digits allowed when representingnumeric values in a Field object

Status

Returns the status of a Field object

Type

Sets or returns the type of a Field object

UnderlyingValue

Returns the current value of a field

Value

Sets or returns the value of a Field object

Methods

Method

Description

AppendChunk

Appends long binary or character data to a Field object

GetChunk

Returns all or a part of the contents of a large text or binary dataField object

Collections

Collection

Description

Properties

Contains all the Property objects for a Field object

Parameter Object

The ADO Parameter object provides information about a single parameterused in a stored procedure or query.

A Parameter object is added to the Parameters Collection when it iscreated. The Parameters Collection is associated with a specific Commandobject, which uses the Collection to pass parameters in and out of storedprocedures and queries.

Parameters can be used to create Parameterized Commands. These commandsare (after they have been defined and stored) using parameters to altersome details of the command before it is executed. For example, an SQLSELECT statement could use a parameter to define the criteria of a WHEREclause.

There are four types of parameters: input parameters, output parameters,input/output parameters and return parameters.

Syntax

objectname.propertyobjectname.method

Properties

Property

Description

Attributes

Sets or returns the attributes of a Parameter object

Direction

Sets or returns how a parameter is passed to or from a procedure

Name

Sets or returns the name of a Parameter object

NumericScale

Sets or returns the number of digits stored to the right side of thedecimal point for a numeric value of a Parameter object

Precision

Sets or returns the maximum number of digits allowed when representingnumeric values in a Parameter

Size

Sets or returns the maximum size in bytes or characters of a value in aParameter object

Type

Sets or returns the type of a Parameter object

Value

Sets or returns the value of a Parameter object

Methods

Method

Description

AppendChunk

Appends long binary or character data to a Parameter object

Delete

Deletes an object from the Parameters Collection

Property Object

The ADO Property object represents a dynamic characteristic of an ADOobject that is defined by the provider.

Each provider that talks with ADO has different ways of interacting withADO. Therefore, ADO needs to store information about the provider in someway. The solution is that the provider gives specific information(dynamic properties) to ADO. ADO stores each provider property in aProperty object that is again stored in the Properties Collection. TheCollection is assigned to either a Command object, Connection object,Field object, or a Recordset object.

ProgID

set objProperty=Server.CreateObject("ADODB.property")

Properties

Property

Description

Attributes

Returns the attributes of a Property object

Name

Sets or returns a the name of a Property object

Type

Returns the type of a Property object

Value

Sets or returns the value of a Property object

Record Object (ADO version 2.5)

The ADO Record object is used to hold a row in a Recordset, a directory,or a file from a file system.

Only structured databases could be accessed by ADO in versions prior 2.5.In a structured database, each table has the exact same number of columnsin each row, and each column is composed of the same data type.

The Record object allows access to data-sets where the number of columnsand/or the data type can be different from row to row.

Syntax

objectname.propertyobjectname.method

Properties

Property

Description

ActiveConnection

Sets or returns which Connection object a Record object belongs to

Mode

Sets or returns the permission for modifying data in a Record object

ParentURL

Returns the absolute URL of the parent Record

RecordType

Returns the type of a Record object

Source

Sets or returns the src parameter of the Open method of a Record object

State

Returns the status of a Record object

Methods

Method

Description

Cancel

Cancels an execution of a CopyRecord, DeleteRecord, MoveRecord, or Opencall

Close

Closes a Record object

CopyRecord

Copies a file or directory to another location

DeleteRecord

Deletes a file or directory

GetChildren

Returns a Recordset object where each row represents the files in thedirectory

MoveRecord

Moves a file or a directory to another location

Open

Opens an existing Record object or creates a new file or directory

Collections

Collection

Description

Properties

A collection of provider-specific properties

Fields

Contains all the Field objects in the Record object

The Fields Collection's Properties

Property

Description

Count

Returns the number of items in the fields collection. Starts at zero.

Example:

countfields = rec.Fields.Count

Item(named_item/number)

Returns a specified item in the fields collection.

Example:

itemfields = rec.Fields.Item(1)oritemfields = rec.Fields.Item("Name")

Recordset Object

The ADO Recordset object is used to hold a set of records from a databasetable. A Recordset object consist of records and columns (fields).

In ADO, this object is the most important and the most used object tomanipulate data from a database.

ProgID

set objRecordset=Server.CreateObject("ADODB.recordset")

When you first open a Recordset, the current record pointer will point tothe first record and the BOF and EOF properties are False. If there areno records, the BOF and EOF property are True.

Recordset objects can support two types of updating:

* Immediate updating - all changes are written immediately to the

database once you call the Update method.

* Batch updating - the provider cache multiple changes and then send

them to the database with the UpdateBatch method.

In ADO there are 4 different cursor types defined:

* Dynamic cursor - Allows you to see additions, changes, and deletions

by other users.

* Keyset cursor - Like a dynamic cursor, except that you cannot see

additions by other users, and it prevents access to records that otherusers have deleted. Data changes by other users will still be visible.

* Static cursor - Provides a static copy of a recordset for you to use

to find data or generate reports. Additions, changes, or deletions byother users will not be visible. This is the only type of cursorallowed when you open a client-side Recordset object.

* Forward-only cursor - Allows you to only scroll forward through the

Recordset. Additions, changes, or deletions by other users will not bevisible.

The cursor type can be set by the CursorType property or by theCursorType parameter in the Open method.

Note: Not all providers supports all methods or properties of theRecordset object.

Properties

Property

Description

AbsolutePage

Sets or returns a value that specifies the page number in the Recordsetobject

AbsolutePosition

Sets or returns a value that specifies the ordinal position of thecurrent record in the Recordset object

ActiveCommand

Returns the Command object associated with the Recordset

ActiveConnection

Sets or returns a definition for a connection if the connection isclosed, or the current Connection object if the connection is open

BOF

Returns true if the current record position is before the first record,otherwise false

Bookmark

Sets or returns a bookmark. The bookmark saves the position of thecurrent record

CacheSize

Sets or returns the number of records that can be cached

CursorLocation

Sets or returns the location of the cursor service

CursorType

Sets or returns the cursor type of a Recordset object

DataMember

Sets or returns the name of the data member that will be retrieved fromthe object referenced by the DataSource property

DataSource

Specifies an object containing data to be represented as a Recordsetobject

EditMode

Returns the editing status of the current record

EOF

Returns true if the current record position is after the last record,otherwise false

Filter

Sets or returns a filter for the data in a Recordset object

Index

Sets or returns the name of the current index for a Recordset object

LockType

Sets or returns a value that specifies the type of locking when editing arecord in a Recordset

MarshalOptions

Sets or returns a value that specifies which records are to be returnedback to the server

MaxRecords

Sets or returns the maximum number of records to return to a Recordsetobject from a query

PageCount

Returns the number of pages with data in a Recordset object

PageSize

Sets or returns the maximum number of records allowed on a single page ofa Recordset object

RecordCount

Returns the number of records in a Recordset object

Sort

Sets or returns the field names in the Recordset to sort on

Source

Sets a string value or a Command object reference, or returns a Stringvalue that indicates the data source of the Recordset object

State

Returns a value that describes if the Recordset object is open, closed,connecting, executing or retrieving data

Status

Returns the status of the current record with regard to batch updates orother bulk operations

StayInSync

Sets or returns whether the reference to the child records will changewhen the parent record position changes

Methods

Method

Description

AddNew

Creates a new record

Cancel

Cancels an execution

CancelBatch

Cancels a batch update

CancelUpdate

Cancels changes made to a record of a Recordset object

Clone

Creates a duplicate of an existing Recordset

Close

Closes a Recordset

CompareBookmarks

Compares two bookmarks

Delete

Deletes a record or a group of records

Find

Searches for a record in a Recordset that satisfies a specified criteria

GetRows

Copies multiple records from a Recordset object into a two-dimensionalarray

GetString

Returns a Recordset as a string

Move

Moves the record pointer in a Recordset object

MoveFirst

Moves the record pointer to the first record

MoveLast

Moves the record pointer to the last record

MoveNext

Moves the record pointer to the next record

MovePrevious

Moves the record pointer to the previous record

NextRecordset

Clears the current Recordset object and returns the next Recordset objectby looping through a series of commands

Open

Opens a database element that gives you access to records in a table, theresults of a query, or to a saved Recordset

Requery

Updates the data in a Recordset by re-executing the query that made theoriginal Recordset

Resync

Refreshes the data in the current Recordset from the original database

Save

Saves a Recordset object to a file or a Stream object

Seek

Searches the index of a Recordset to find a record that matches thespecified values

Supports

Returns a boolean value that defines whether or not a Recordset objectsupports a specific type of functionality

Update

Saves all changes made to a single record in a Recordset object

UpdateBatch

Saves all changes in a Recordset to the database. Used when working inbatch update mode

Events

Note: You cannot handle events using VBScript or JScript (only VisualBasic, Visual C++, and Visual J++ languages can handle events).

Event

Description

EndOfRecordset

Triggered when you try to move to a record after the last record

FetchComplete

Triggered after all records in an asynchronous operation have been fetched

FetchProgress

Triggered periodically in an asynchronous operation, to state how manymore records that have been fetched

FieldChangeComplete

Triggered after the value of a Field object change

MoveComplete

Triggered after the current position in the Recordset has changed

RecordChangeComplete

Triggered after a record has changed

RecordsetChangeComplete

Triggered after the Recordset has changed

WillChangeField

Triggered before the value of a Field object change

WillChangeRecord

Triggered before a record change

WillChangeRecordset

Triggered before a Recordset change

WillMove

Triggered before the current position in the Recordset changes

Collections

Collection

Description

Fields

Indicates the number of Field objects in the Recordset object

Properties

Contains all the Property objects in the Recordset object

The Fields Collection's Properties

Property

Description

Count

Returns the number of items in the fields collection. Starts at zero.

Example:

countfields = rs.Fields.Count

Item(named_item/number)

Returns a specified item in the fields collection.

Example:

itemfields = rs.Fields.Item(1)oritemfields = rs.Fields.Item("Name")

The Properties Collection's Properties

Property

Description

Count

Returns the number of items in the properties collection. Starts at zero.

Example:

countprop = rs.Properties.Count

Item(named_item/number)

Returns a specified item in the properties collection.

Example:

itemprop = rs.Properties.Item(1)oritemprop = rs.Properties.Item("Name")

Stream Object (ADO version 2.5)

The ADO Stream Object is used to read, write, and manage a stream ofbinary data or text.

A Stream object can be obtained in three ways:

* From a URL pointing to a document, a folder, or a Record object* By instantiating a Stream object to store data for your application* By opening the default Stream object associated with a Record object

Syntax

objectname.propertyobjectname.method

Properties

Property

Description

CharSet

Sets or returns a value that specifies into which character set thecontents are to be translated. This property is only used with textStream objects (type is adTypeText)

EOS

Returns whether the current position is at the end of the stream or not

LineSeparator

Sets or returns the line separator character used in a text Stream object

Mode

Sets or returns the available permissions for modifying data

Position

Sets or returns the current position (in bytes) from the beginning of aStream object

Size

Returns the size of an open Stream object

State

Returns a value describing if the Stream object is open or closed

Type

Sets or returns the type of data in a Stream object

Methods

Method

Description

Cancel

Cancels an execution of an Open call on a Stream object

Close

Closes a Stream object

CopyTo

Copies a specified number of characters/bytes from one Stream object intoanother Stream object

Flush

Sends the contents of the Stream buffer to the associated underlyingobject

LoadFromFile

Loads the contents of a file into a Stream object

Open

Opens a Stream object

Read

Reads the entire stream or a specified number of bytes from a binaryStream object

ReadText

Reads the entire stream, a line, or a specified number of characters froma text Stream object

SaveToFile

Saves the binary contents of a Stream object to a file

SetEOS

Sets the current position to be the end of the stream (EOS)

SkipLine

Skips a line when reading a text Stream

Write

Writes binary data to a binary Stream object

WriteText

Writes character data to a text Stream object

Todo este apendice fue tomado de www.w3schools.com

ADO VISUAL BASIC SCRIPT

MÁS INFORMACIÓN

El contenido original se encuentra en https://programacionfacil.com/visual_basic_script/ado/
Todos los derechos reservados para el autor del contenido original (en el enlace de la linea superior)
Si crees que alguno de los contenidos (texto, imagenes o multimedia) en esta página infringe tus derechos relativos a propiedad intelectual, marcas registradas o cualquier otro de tus derechos, por favor ponte en contacto con nosotros en el mail bitelchux@yahoo.es y retiraremos este contenido inmediatamente