by Kaustubh Zoal (10 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 21st June 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Using the Data Shape
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim rstTitleAuthor As New ADODB.Recordset
cnn.Provider = "MSDataShape"
cnn.Open "Data Provider=SQLOLEDB.1;" & _
"Data Source=URServerName;User Id=sa;Password=;Database=Pubs"
' STEP 1
rst.StayInSync = False
rst.Open "SHAPE {select * from authors} " & _
"APPEND ({select * from titleauthor} " & _
"RELATE au_id TO au_id) AS chapTitleAuthor", _
cnn
' STEP 2
While Not rst.EOF
Debug.Print rst("au_fname"), rst("au_lname"), _
rst("state"), rst("au_id")
' STEP 3
Set rstTitleAuthor = rst("chapTitleAuthor").Value
' STEP 4
While Not rstTitleAuthor.EOF
Debug.Print rstTitleAuthor(0), rstTitleAuthor(1), _
rstTitleAuthor(2), rstTitleAuthor(3)
rstTitleAuthor.MoveNext
Wend
rst.MoveNext
Wend
With grdTemp
Set .Recordset = rst
.Refresh
End With
rst.Close
cnn.Close
End Sub