Refreshing a Collection
When you use the Refresh collection method, SQL-DMO refreshes objects with current information from SQL Server. The Refresh method takes a single Boolean parameter, indicating if you want to release all objects in the collection and "under" the collection in the SQL-DMO hierarchy.
-
If True, SQL-DMO releases all objects in the collection and all objects "under" the collection. SQL-DMO then refreshes the collection with current information from SQL Server. All objects "under" the refreshed collection are reinitialized, and current information will be retrieved from SQL Server as you use them. This invalidates all object variables you have that refer to any object in the refreshed collection, or to any object "under" the refreshed collection.
-
If False, SQL-DMO releases only those objects in the collection that have been dropped from SQL Server. SQL-DMO then refreshes the entire collection with current information from SQL Server. It will not release or refresh any objects "under" the collection. This invalidates any object variables you have that refer to objects that are no longer in the refreshed collection because they have been dropped from SQL Server.
Some objects that cache a lot of SQL Server information have a direct Refresh method.
Visual Basic
To use the Refresh collection method, use the following syntax:
Parent.Objects.Refresh ( bRelease )
Do not call Refresh within a For Each loop.
C++
To use the Refresh collection method, use the following syntax:
pObjects->Refresh ( bRelease );