Returning a Recordset as a String

Instead of using a loop to read the values of fields in all rows of the open recordset, you can use the Recordset object's GetString method to get the desired data in one step. The GetString method returns a recordset as a string-valued Variant. This method has the following syntax:

Variant = Recordset.GetString(StringFormat, NumRows, _ ColumnDelimiter, RowDelimiter, NullExpr)

The first argument (StringFormat) determines the format for representing the recordset as a string. Use the adAddClipString constant as the value for this argument.

The second argument (NumRows) specifies the number of recordset rows to return. If blank, GetString will return all the rows. The third argument (ColumnDelimiter) specifies the delimiter for the columns within the row (the default column delimiter is tab (vbTab)). The fourth argument (RowDelimiter) specifies a row delimiter (the default is carriage return (vbCrLf)).

The fifth argument (NullExpr) specifies an expression to represent Null values (the default is an empty string (" ")).

Creating and Manipulating Databases with ADO

0 0

Post a comment