Creazione di recordset gerarchici
Nell'esempio seguente viene illustrato come creare un oggetto Recordset gerarchico senza una fonte dati sottostante usando la sintassi del data shaping per definire colonne per i Recordset padre, figlio e nipote Recordset.
Per creare un recordset gerarchico, è necessario specificare il microsoft data shaping service for OLE DB (ADO Service Provider) (MSDataShape) ed è possibile specificare un valore del provider di dati NONE nel parametro della stringa di connessione del metodo Open dell'oggetto Connection. Per informazioni aggiuntive, vedere Provider necessari per il data shaping.
Dim cn As New ADODB.Connection
Dim rsCustomers As New ADODB.Recordset
cn.Open "Provider=MSDataShape;Data Provider=NONE;"
strShape = _
"SHAPE APPEND NEW adInteger AS CustID," & _
" NEW adChar(25) AS FirstName," & _
" NEW adChar(25) AS LastName," & _
" NEW adChar(12) AS SSN," & _
" NEW adChar(50) AS Address," & _
" ((SHAPE APPEND NEW adChar(80) AS VIN_NO," & _
" NEW adInteger AS CustID," & _
" NEW adChar(20) AS BodyColor, " & _
" ((SHAPE APPEND NEW adChar(80) AS VIN_NO," & _
" NEW adChar(20) AS Make, " & _
" NEW adChar(20) AS Model," & _
" NEW adChar(4) AS Year) " & _
" AS VINS RELATE VIN_NO TO VIN_NO))" & _
" AS Vehicles RELATE CustID TO CustID) "
rsCustomers.Open strShape, cn, adOpenStatic, adLockOptimistic, -1
Non appena il recordset è stato creato, può essere popolato, modificato o salvato in modo permanente in un file.
Vedere anche
Accesso alle righe in un recordset gerarchico
Grammatica formale delle forme
provider necessari per il data shaping
Shape clausola APPEND
Comandi di forma in generale