ASP in Nutshell by O'Reilly

ASP in Nutshell by O'Reilly

Author:O'Reilly [O'Reilly]
Language: fra
Format: epub, pdf
Tags: Informatique
Publisher: O'Reilly
Published: 1999-11-12T11:56:50+00:00


Description (Error Object)

Notes

The CursorType property of the Recordset object is read-only if the recordset is

already open but read/write otherwise.

If you attempt to set the CursorType property to a value not supported by your

underlying data provider, the data provider may return a cursor of a different type

than you set. However, if this happens, the CursorType property value reflects this

change. Then, once the recordset is closed, the CursorType property value reverts

to the value you set. You can use the Supports method of the Recordset object to

determine which cursors are supported by a given data provider, according to

Table 11-19.

Table 11-19: Determining if a Data Provider Supports a Cursor Type

If Supported, Method Returns True

with These Parameters

Cursor Type Supported

None

adOpenForwardOnly

adBookmark, adHoldRecords, adMovePrevious,

adOpenKeyset

adResync

adMovePrevious

adOpenDynamic

adBookmark, adHoldRecords, adMovePrevious,

adOpenStatic

adResync

What happens if one of the tests on the right fail for your selected cursor type?

Suppose you attempt to set the CursorType to one of the cursor type constants in

the right column, but one or more of the Supports method calls in the left column

returns False. The result is unpredictable, but most often the underlying data

provider will simply change the cursor type when you attempt to open the

recordset.

Description (Error Object)

objError.Description

A read-only string that provides textual information describing the error that the

underlying data provider raised in response to incorrect syntax or lack of support.

Description is a property of each Error object in the Connection object’s Errors

collection. It is not the same as the Description property of the ASP Err object.

Parameters

None

Example

The following example demonstrates the use of the Description property of the

Error object. Notice that for this example to work properly, the Response object’s

Buffer property must be set to True because we use the Response’s object’s Clear

and End methods.

<%@ LANGUAGE="VBSCRIPT" %>

190 Chapter 11 – ActiveX Data Objects 1.5

ASP in a Nutshell: A Desktop Quick Reference, eMatter Edition

Copyright © 2000 O’Reilly & Associates, Inc. All rights reserved.

Description (Error Object)

<%Response.Buffer = True%>

<HTML>

<HEAD>

<TITLE>ADO Examples</TITLE>

</HEAD>

<BODY>

<%

ActiveX Data

Objects 1.5

' Include ADOVBS.INC so we can use the ADO constants.

%>

<!-- #include virtual = "/MySSIncludes/adovbs.inc" -->

<%

' Instantiate an ADO Connection object.

Set objDBConn = Server.CreateObject("ADODB.Connection")

' Construct the connection string for the Connection

' object.

strConn = _

"driver={MyDBType};;uid=sa;pwd=;database=SalesDB"

' Using the connection string, open the connection.

objDBConn.Open strConn

' Check if attempting to open a connection to the

' provider resulted in ADO adding Error objects to the

' Connection's Errors collection.

If objDBConn.Errors.Count > 0 Then

' An error occurred and ADO added an Error object to

' the Connection's Errors collection. Clear the

' Response buffer and alert the user of the error.

Response.Clear

Response.Write _

"One or more errors have occurred.<BR>"

For intCounter = 0 to objDBConn.Errors.Count

Response.Write "The " & intCounter & " error's "

Response.Write "error number is " & _

objDBConn.Errors(intCounter).Number & ".<BR>"

Response.Write "The description for this "

Response.Write "error is <BR>" & _

objDBConn.Errors(intCounter).Description & ".<BR>"

Next

Response.End

End If

...[additional code]

Notes

Each time an error occurs in the data provider, ADO adds an Error object to the

Errors collection of the Connection object corresponding to that data provider. The

provider is responsible for generating and sending the actual error text to ADO,

but ADO can modify it before setting the description that it adds to the Connec-

tion object’s Errors collection.

Description (Error Object) 191

ASP in a Nutshell: A Desktop Quick Reference, eMatter Edition

Copyright © 2000 O’Reilly & Associates, Inc.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.