Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleConnect a DataReport to an ADO Recordset
KeywordsDataReport, ADO, Recordset
CategoriesDatabase
 
Open a Connection object to the database. Use the Connection object's Execute method to create a Recordset containing the desired records.

Then set the DataReport's DataSource property to the Recordset and display the DataReport.

 
Private Sub Command1_Click()
Dim db_file As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

    ' Get the data.
    db_file = App.Path
    If Right$(db_file, 1) <> "\" Then db_file = db_file & _
        "\"
    db_file = db_file & "books.mdb"

    ' Open a connection.
    Set conn = New ADODB.Connection
    conn.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & db_file & ";" & _
        "Persist Security Info=False"
    conn.Open

    ' Open the Recordset.
    Set rs = conn.Execute("SELECT * FROM Books", , _
        adCmdText)

    ' Connect the Recordset to the DataReport.
    Set rptBooks.DataSource = rs
    rptBooks.WindowState = vbMaximized
    rptBooks.Show vbModal

    rs.Close
    conn.Close
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated