Printing the contents of a database.

lofttyme
10-21-2004, 09:05 AM
Hi All,

I have read in a database useing this method




Private Sub Command1_Click()
Dim openDatabase As Long
CommonDialog1.DialogTitle = "Choose Qwest database"
CommonDialog1.CancelError = False
CommonDialog1.Filter = "Access database (*.mdb*)|*.mdb*"
CommonDialog1.ShowOpen


Text1.Text = CommonDialog1.FileName
rst.CursorType = adOpenKeyset
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Text1.Text & ";Persist Security Info=False"
rst.Open "Select * From Details", Adodc1.ConnectionString, adOpenKeyset, adLockOptimistic
Set Adodc1.Recordset = rst

Set rst = Nothing

End Sub


How can I print out the whole contents of that database?

Thanks

Loftty

loquin
10-21-2004, 11:51 AM
First, take a look at Optikal's ADO Tutorial in the ***. Personally, I would avoid the ado data controls entirely.


Dim your connection and recordset.

Create new instances of the connection and recordset

Open the Connection

Open the recordset

Get the field names for use as headers in your report
Dim N as Integer
For N = 0 to rs.Fields.Count-1
Printer.Print rs.Fields(n).Name & space(10); ' You'll need to work on this to get the alignment correct
Next N
Printer.Print

Now, Loop through the recordset using the Do-Loop
Do While Not rs.EOF
' Process the Recordset
For N = 0 to rs.Fields.Count-1
Printer.Print rs.Fields(n).Value & space(10);
Next N
Printer.Print 'Kick out a new Line
rs.MoveNext
Loop

Printer.EndDoc
Finally, close your objects & release them (SET them = to nothing...)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum