SetRootRecordset Method

Microsoft Office Web Components Object Model

SetRootRecordset Method

       

Sets the root recordset for the specified DataSourceControl object. Use this method to change the recordset to which a data access page is bound.

expression.SetRootRecordset(RecordsetName, Recordset)

expression   Required. An expression that returns a DataSourceControl object.

RecordsetName  Required String. The name to use for the new recordset. If the DataSource control contains a recordset of this name, it will be replaced.

Recordset  Required Recordset object. The ADO recordset.

Remarks

This method supports connecting to any ADO recordset.

Example

This example changes the root recordset used by the data source control.

Sub ChangeRootRecordset()
   Dim rstCategories
   Dim strShapeText
   Dim strConnectionString

   strShapeText = MSODSC.RootRecordsetDefs(0).ShapeText

   strConnectionString = "Provider=MSDataShape.1;Persist Security Info=True;Data Source" &
                        "=sqlsvr;User ID=sa;Password="""";Initial Catalog=Northwind;" &
                        "Data Provider=SQLOLEDB.1"

   Set rstCategories = CreateObject("ADODB.Recordset")

   rstCategories.Open strShapeText, strConnectionString, 1, 3

   MSODSC.SetRootRecordset "Categories", rstCategories

End Sub