Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

HOWTO: How to Use SQL Pass-Through to Send Results to a Table


View products that this article applies to.

This article was previously published under Q138998

↑ Back to the top


Summary

The FoxPro 2.x Connectivity Kit allows you to send the results of the DBExec() function to a table by using the DBSetOpt() function and setting the UseTable property of the connection to 1. Visual FoxPro has no property that causes the results of the SQLExec() function to be sent to a table.

↑ Back to the top


More information

The results of the SQLExec() function are always returned to a cursor. The default cursor name is Sqlresult. To send the results to a table, use the COPY TO command after calling the SQLExec() function. The COPY TO command creates a table from the Sqlresult cursor.

The following example creates a table called Temp.dbf from the results of a SQLExec() function. Create a new program containing the following code:
   datasrcname='test'    &&Data Source Name - from ODBC administrator
   userid='sa'           &&User ID
   pword=''              &&User Password

   ** Establish a connection **
   handle=SQLConnect(datasrcname, userid, pword)

   ** Execute query **
   =SQLExec(handle, 'select * from authors')

   ** Copy results to a table **
   COPY TO TEMP.DBF

   ** Close the cursor **
   SELECT Sqlresult
   USE

   ** End the connection **
   =SQLDisconnect(handle)
					
When this program is run, the results of the SQLEXEC() function are stored in the Temp.dbf table.

↑ Back to the top


Keywords: KB138998, kbhowto

↑ Back to the top

Article Info
Article ID : 138998
Revision : 4
Created on : 3/14/2005
Published on : 3/14/2005
Exists online : False
Views : 493