Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems


ADO Collections Refresh Method

Updates the objects in a collection to reflect objects available from and specific to the provider.

Refresh Method Applies To

ADO Fields Collection, ADO Parameters Collection, ADO Properties Collection

Refresh Method Syntax


Refresh Method Parameters Collection

Using the Refresh method on a ADO Command Object object's Parameters collection retrieves provider-side parameter information for the stored procedure or parameterized query specified in the Command object. The collection will be empty for providers that do not support stored procedure calls or parameterized queries.

You should set the ActiveConnection property of the Command object to a valid ADO Connection Object, the ADO Command Object CommandText Property to a valid command, and the ADO Command Object CommandType Property to adCmdStoredProc before calling the ADO Collections Refresh Method.

If you access the Parameters collection before calling the Refresh method, ADO will automatically call the method and populate the collection for you.


If you use the Refresh method to obtain parameter information from the provider and it returns one or more variable-length data type ADO Parameter Object objects, ADO may allocate memory for the parameters based on their maximum potential size, which will cause an error during execution. You should explicitly set the ADO Parameter Object Size Property for these parameters before calling the ADO Command Object Execute Method to prevent errors.

Refresh Method Fields Collection

Using the Refresh method on the Fields collection has no visible effect. To retrieve changes from the underlying database structure, you must use either the ADO Recordset Object Requery Method or, if the Recordset object does not support bookmarks, the ADO Recordset Object MoveFirst, MoveLast, MoveNext, MovePrevious Methods method.

Refresh Method Properties Collection

Using the Refresh method on a Properties collection of some objects populates the collection with the dynamic properties the provider exposes. These properties provide information about functionality specific to the provider beyond the built-in properties ADO supports.

The Refresh method accomplishes different tasks depending on the collection from which you call it.

Refresh Method Example

This Visual Basic example demonstrates using the Refresh method to refresh the Parameters collection for a stored procedure Command object.

Public Sub RefreshX()

Dim cnn1 As ADODB.Connection

Dim cmdByRoyalty As ADODB.Command

Dim rstByRoyalty As ADODB.Recordset

Dim rstAuthors As ADODB.Recordset

Dim intRoyalty As Integer

Dim strAuthorID As String

Dim strCnn As String

' Open connection.

Set cnn1 = New ADODB.Connection

strCnn = "driver={SQL Server};server=srv;" & _


cnn1.Open strCnn

' Open a command object for a stored procedure

' with one parameter.

Set cmdByRoyalty = New ADODB.Command

Set cmdByRoyalty.ActiveConnection = cnn1

cmdByRoyalty.CommandText = "byroyalty"

cmdByRoyalty.CommandType = adCmdStoredProc


' Get paramater value and execute the command,

' storing the results in a recordset.

intRoyalty = Trim(InputBox("Enter royalty:"))

cmdByRoyalty.Parameters(1) = intRoyalty

Set rstByRoyalty = cmdByRoyalty.Execute()

` Open the Authors table to get author names for display.

Set rstAuthors = New ADODB.Recordset

rstAuthors.Open "authors", cnn1, , , adCmdTable

' Print current data in the recordset, adding

' author names from Authors table.

Debug.Print "Authors with " & intRoyalty & " percent royalty"

Do While Not rstByRoyalty.EOF

strAuthorID = rstByRoyalty!au_id

Debug.Print " " & rstByRoyalty!au_id & ", ";

rstAuthors.Filter = "au_id = '" & strAuthorID & "'"

Debug.Print rstAuthors!au_fname & " " & _







End Sub

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.