ADO  Activex Data Object

 

Connection
   Error Collection                                                                                           
   Errors Object's

Command
    Parameters collection
    Parameters Object's

Recordset
    Fields collection
    Fields Object's

Cursor types
Locking type

Eksempel

   

Connection Object

Properties

Metods

attribute Specified wheather a new transaction will be started after a transaction rollback or commit BeginTrans Begins a transaction
CommandTimeOut How long to wait for a command to process.Default is 30 secounds.Setting the values to 0 will make the wait indefinite. CommitTrans Commits the transaction to disk
ConnectionString The DSN, provider,username and password, and other information neseserry to connect to the database. RollBackTrans Rolls back the transaction
ConnectionTimeout How long to wait to connect to the datasource.Default is 15 secounds.Setting the values to 0 will make the wait indefinite. Close Close  the connection
DefaultDatabase If the database you are connection to enables multiple databases, this property enables you to specify wich one is the default. Execute Execute  a command on the datasource, returnin a recordset
Isolation The isolation level of the connection Open Opens the connection
Mode Used to set the permissions on a connection, such as read-only or read-write
Provider The provider of a connection
Version The version of ADO being used

 

 

The Error Collection

Properties

Metods

Count The number of error objects in the collection Clear Removes all the objects in the collection
Item Returns a specific error object by name or number

 

 

The Error Object´s

Properties

Metods

Description The description of the error
HelpContext The help topic in the help file that contains more information on the error.

No methods

No methods

HelpFile The filename of the help file that has more information on the error
NativeError This is a provider-specific code
Number A unique ID to disquish this error object from others in the error collection.
Source The name of the application(or object) that returned the error.
SQLState the five-digit SQL-error code

 

Command Object

Properties

Metods

ActiveConnection Specifies the connection object the command object belongs to CreateObject Create new parameter object.
CommandText A string that indicate the command to run against the datasource. Execute Execute the command stored in the commandTextProperty
CommandTimeOut Specifies how long time to wait for a command to execute. Default is 30 sec.
CommandType The type of the command.
Prepared Tells the provider to prepare, or compile, the command before execution.

 

 

Parameter Collection

Properties

Metods

Count The number of parameters object in the collection. Append Adds a new parameter to the collection
Item A specific parameter in the collection. Delete Deletes a parameter fromthe collection.
Refresh Retrives information from the provider on the parameters in the stored procedure specified in the commandText property

 

 

Parameter Object's

Properties

Metods

Attributes Indicates what type of data the parameter accepts. AppendChunck Appends a large amount of data to a parameter object.
Direction Indicates wheather the parameter is an input or output parameter, or both.
Name The parameter's name
NumericScale For numeric parameters values, indicate the number of digits to the right of the decimal point that will be resolved to
Precision For numeric parameter values, indicates the number of digits that will be used.
Size The maximum size, in bytes of the parameter object
Type The data type of the parameter.
Value The value of the parameter.

 

Recordset Object

Properties

Metods

AbselutPage Witch page the current record is on Add New Create new record
AbselutePossion The place in the recordset the current record is on. CancelBatch Cancel a pending batch update
ActiveConnection The current connection the recordset is using CancelUpdate Cancels the change made to a recordset
BOF Beginning of file Clone Create a recordset with the records in the current recordset.
EOF End of file Close Close the recordset.
BookMark A unique reference in a recordset. Delete Delete the current Record
CachSize The number of records stored in memory of the client machine. GetRows Copies the specified records into a array.
CurserType The type of curser to open the recordset with. Move Moves to a specific recod.
EditMode Indicate wheather the current record is being edited or added. MoveFirst Moves to the record specified in the name
Filter Filters a recordset MoveLast Moves to the record specified in the name
LockType The type of locking the recordset wil enforce MoveNext Moves to the record specified in the name
MaxRecords The maximum numbers of records the recordset wil return. MovePrevious Moves to the record specified in the name
PageCount The number of pages in the recordset NextRecordset Close the current recordset and open the next
PageSize The number of page a record a page will have. Open Open a recordset
RecordCount The number of record in the recordset. Requery ReRuns the query and updates the recordset.
Source The source of the recordset (That is a table or query). Resync Syncs up with the database. Updates any locally catched records.
Status The status of a record. Supports Indicates wheather certain functions will be present in the datasource
Update Save the changes made to the current record
UpdateBatch Save the changes from the batch update.

 

Field Collection

Properties

Metods

Count The number of fields in the collection Refresh This really doesn't do anything, you will need to use the recordset's requery method to refresh a field collection
Item The specific field in the collection

 

Field Object's

Properties

Metods

ActualSize The actual length of the data AppendChunck Appends data to a field
Attribute This is data for the field. GetChunck Gets data from a field
DefinedSize The maximum size for the field
Name The name of the field
NumericScale For numeric field values, indicates the number of digits to the right of the decimal point that it will be resolved to.
OriginalValue The value of the field before it was changed.
Precision For numeric field values, indicates the number of digits that the field will be resolved to.
Type The type of data.
UnderlyingValue The current value of the field in the database.
Value The actual value of the field.

 

The ActiveX Data Objects (ADO) cursor provider, part of the Remote Data Service (RDS) technology, provides several types of cursors as shown in the following table.

Cursor type Constant
Forward-only cursor adOpenForwardOnly
Keyset-driven cursor adOpenKeyset
Dynamic cursor adOpenDynamic
Static cursor adOpenStatic

You can control how the data source and the chosen ADO cursor library manage concurrency with the locking options in the following table.

Locking type Constant
Pessimistic concurrency. adLockPessimistic
Optimistic concurrency using row values. adLockOptimistic
Read-only. Changes are not permitted. adLockReadOnly
All updates are deferred until the batch update is finished. To do batch updating, you should select either a keyset or static cursor. adLockBatchOptimistic

 

Eksempler

Set rs_people = Server.CreateObject("ADODB.Recordset")
Set rs_places = Server.CreateObject("ADODB.Recordset")
rs_people.Open "Select * from tbl_people", "DSN=PeopleAndPlaces"
rs_places.Open "Select * from qry_places", "DSN=PeopleAndPlaces"

What is so bad about the above code? For starters, two Connection objects are being created. 'Mere is only need for one. So resources are being wasted. Second, the command object could be used to manage the opening of these recordsets, which would result in improved performance.

Listing 20.9 is another code snippet (which should look pretty familiar by now) opening these same recordsets in a more appropriate manner.

Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "DSN= PeopleAndPlaces"
Set DataCmd = Server.CreateObject("ADODB.Command")
DataCmd.CommandText = "tbl_people"
DataCmd.CommandType = adCmdTbl
Set DataCmd.Activeconnection = DataConn
Set rs_people = Server.CreateObject("ADODB.Recordset")
rs_people.Open DataCmd
DataCmd.CommandText = "qry_places'
DataCmd.CommandType = adCmdStoredProc
Set rs_places = Server.CreateObject("ADODS.Recordset")
rs_places.Open DataCmd

 

Brug denne metode med  ADO , da den også optimere kaldet, da alt bliver udført i ram.

Datacon.BeginTrans

     '  Code her

If DataConn.errors.count = 0 then
 DataConn.CommitTrans
Else
    DataConn.RollBackTrans
End if