[ACCEPTED]-How to check all fields of the recordset from ADO query?-ado

Accepted answer
Score: 13

First off, Debug.Print prints to the Immediate Window 11 in the VB[A] Editor. If it's not showing, press 10 Ctrl-G.

Second, there is no single command 9 to show the whole record, you'll have to 8 assemble it the way that Xavinou does in 7 his (her?) answer. Here's the VB syntax, ignoring 6 recordset creation & EOF check (Note 5 that I've declared the variables--you are 4 using Option Explicit, yes?):

Dim fld As Field
Dim msg As String

    For Each fld In rstRecordSet.Fields
        msg = msg & fld.Value & "|"

Debug.Print msg    'or MsgBox msg 

I think the 3 pipe ("|") makes a better separator than 2 a space, since it's less likely to occur 1 in your data.

Score: 2

For the output console, I don't know (since 4 I don't know VB), but for showing the whole 3 record at once, you can use a foreach loop on rstRecordSet.Fields.

In 2 C#, I would write it like :

string msg = "";
foreach (Field f in rstRecordSet.Fields)
    msg += f.Value + " ";

Now, you just 1 have to find the VB syntax...

Score: 0

Instead of building your own string, piece 3 by piece, you can use the GetString method of the Recordset object:

Debug.Print records.GetString(adClipString, 1)

An unfortunate 2 side effect of this method is that it seems 1 to remove the record from the record set.

More Related questions