SQLRetrieveToFile (function)

Syntax SQLRetrieveToFile (ID,destination$ [,[isColumnNames] [,delimiter$]])
Description Retrieves the results of a query and writes them to the specified file.
Comments The following table describes the parameters to the SQLRetrieveToFile function:
Parameter Description
ID Long specifying a valid connection ID.
destination String specifying the file where the results are written.
isColumnNames Optional Boolean specifying whether the first row of results returned are the bound column names. By default, the column names are not returned.
delimiter Optional String specifying the column separator. A tab ( Chr$(9) ) is used as the default.
Before you can retrieve the results from a query, you must (1) initiate a query by calling the SQLExecQuery function and (2) specify the fields to retrieve by calling the SQLBind function. This function returns the number of rows written to the file. A runtime error is generated if there are no pending results or if the Basic Control Engine is unable to open the specified file. The Basic Control Engine generates a runtime error if SQLRetrieveToFile fails. Additional error information may be placed in memory for later use with the SQLError function.
Example This example opens a connection, runs a query, binds columns, and writes the results to a file.
Sub Main()
  Dim b() As Variant
  id& = SQLOpen("DSN=SAMPLE;UID=RICH",,4)
  t& = SQLExecQuery(id&,"Select * From c:\sample.dbf")
  i% = SQLBind(id&,b,3)
  i% = SQLBind(id&,b,1)
  i% = SQLBind(id&,b,2)
  i% = SQLBind(id&,b,6)
  l& = SQLRetrieveToFile(id&,"c:\results.txt",True,",")
  id& = SQLClose(id&)
End Sub
See Also SQLOpen (function); SQLExecQuery (function); SQLClose (function); SQLBind (function); SQLRetrieve (function).