Using the GetClipString Method

In situations where you want to fill a grid control or other control that supports bulk loading through its Clip property, you can use the GetClipString method to return a delimited string for 'n' rows of a result set. The resultant string can then be applied to the target control's Clip property, which will populate the control with data from your result set.

The GetClipString method returns a delimited string for 'n' rows in a result set based on its NumRows argument. If more rows are requested than are available, only the available rows are returned. Use the RowCount property to determine how many rows are actually fetched. The number of rows that can be fetched is constrained by available memory and should be chosen to suit your application. Don't expect to use GetClipString to bring your entire table or result set into memory if it is a large table.

Generally, the GetClipString method works just like the GetRows method, except that the data is returned as a string instead of a two-dimensional variant array. GetClipString can be used to fill a grid control or any control that has a Clip property. It can also be used to format export data from a result set to a sequential file.

After a call to GetClipString completes, the current row is positioned at the next unread row. GetClipString is equivalent to using the Move (rows) method.

If you are trying to fetch all the rows using multiple GetClipString calls, use the EOF property to determine if there are rows available. GetClipString returns less than the number requested either at the end of the rdoResultset, or if it cannot fetch a row in the range requested. For example, if a fifth row cannot be retrieved in a group of ten rows that you're trying to fetch, GetClipString returns four rows and leaves currency on the row that caused the problem. It will not generate a run-time error.

The ColumnDelimiter optional parameter can be used to substitute a different column delimiter than the default tab (Chr$(9)) character, and the RowDelimiter optional parameter can be used to substitute a different row delimiter. This is useful when working with a control that accepts a clip format, but requires different characters for the column and row delimiters (some grids have been known to require both a carriage return and a line-feed character for a row delimiter).