Foxpro SQL Server Function Descriptions

Sqlcreate - upload Foxpro table structure to  SQL Server
Sqlappend - upload  Foxpro table records to SQL Server 
Sqlzap - deletes all records in SQL Server table
Sqltop - get first record in SQL Server table
Sqlbot - get last record in SQL Server table
Sqlnext - skip forward through SQL Server table one record at a time
Sqlprior - skip backward through SQL Server table one record at a time
Sqldel - deletes one record in the SQL Server table
Sqlupdate - easily update fields within the SQL Server table 
Sqlinsert -  easily append data to a SQL Server table
Sqlseek - determines if  SQL Server table record exists
Sqlfind -  Search SQL Server table with browse  


SQLCREAT (<expN>,<expC1>,<expC2>)

<expN>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database you would like your table created within.

<expC2>
<expC2> is the SQL Server table name you would like to create.

Returns	Numeric 
		    < 0	error condition

Description:

Creates a SQL Server table from an existing Foxpro table.

Example:

set library to fpsql
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
use test                                                  && open existing foxpro table for structure copy
err=sqlcreate(h,'manf','test')                && create SQL Server table from Foxpro structure

SQLAPPEN (<expN>,<expC1>,<expC2>)

<expN>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like use.

Returns	Numeric 
		    < 0	error condition

Description:

Appends all records from the selected Foxpro table to the SQL Server table. 
If you use SQLAPPEND and SQLCREATE in a procedure you can easily upload your all your Foxpro tables to  SQL Server. 

Example:

set library to fpsql
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
use test                                                  && open existing Foxpro table for table copy
err=sqlappend(h,'manf','test')                && upload data to  SQL Server table

SQLZAP(<expN>,<expC1>,<expC2>)

<expN>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like to zap or clear all rows.

Returns	Numeric 
		    < 0	error condition

Description:

Zaps all records from SQL Server and truncates transaction log.
 

Example:

set library to fpsql
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqlzap(h,'manf','test')                && zap all records in SQL Server table


SQLTOP(<expN1>,<expC1>,<expC2>,<expC3>,<expC4>,<expC5>,<expC6>)

<expN1>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like use.

<expC3>
<expC3> is the SQL Server table field name to order the data by.

<expC4>
<expC4> is the list of fields to return back to a Foxpro table or cursor.

<expC5>
<expC5> is the name of the Foxpro table or cursor to return SQL Server data to.

<expC6>
<expC6> a value of 'dbf' will return SQL Server data to a Foxpro table. A value of 'cursor' will return SQL 	Server data to a Foxpro cursor.

Returns	Numeric 
		    < 0	error condition

Description:

Sends the first record from a SQL Server table to a Foxpro table or cursor. Use this function in your Foxpro edit screen for top of file button.

Example:

set library to fpsql                                 
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqltop(h,'manf','test','empno','empno,first,last,address','newtable','cursor')    && get first record                 
	<manf> name of database your table resides within SQL Server
	<test>   name of SQL Server table you would like first record from
	<empno> name of field of SQL Server table that you would like data ordered (by 			employee number)
	<empno,first,last,address> SQL Server table field list, you may use '*' for all fields
	<newtable> name of table or cursor that you would like SQL Server table data returned 			to.
	<'cursor'> return <newtable> as a cursor
 
                
SQLBOT(<expN1>,<expC1>,<expC2>,<expC3>,<expC4>,<expC5>,<expC6>)

<expN1>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like use.

<expC3>
<expC3> is the SQL Server table field name to order the data by.

<expC4>
<expC4> is the list of fields to return back to a Foxpro table or cursor.

<expC5>
<expC5> is the name of the Foxpro table or cursor to return SQL Server data to.

<expC6>
<expC6> a value of 'dbf' will return SQL Server data to a Foxpro table. A value of 'cursor' will return SQL 	Server data to a Foxpro cursor.

Returns	Numeric 
		    < 0	error condition

Description:

Sends the last record from a SQL Server table to a Foxpro table or cursor. Use this function in your Foxpro edit screen for bottom of file button.

Example:

set library to fpsql                                 
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqlbot(h,'manf','test','empno','empno,first,last,address','newtable','cursor')    && get last record                 
	<manf> name of database your table resides within SQL Server
	<test>   name of SQL Server table you would like first record from
	<empno> name of field of SQL Server table that you would like data ordered (by 			employee number)
	<empno,first,last,address> SQL Server table field list, you may use '*' for all fields
	<newtable> name of table or cursor that you would like SQL Server table data returned 			to.
	<'cursor'> return <newtable> as a cursor
 
                
SQLNEXT(<expN1>,<expC1>,<expC2>,<expC3>,<expC4>,<expC5>,<expC6>,<exp1)

<expN1>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like use.

<expC3>
<expC3> is the SQL Server table field name to order the data by.

<expC4>
<expC4> is the list of fields to return back to a Foxpro table or cursor.

<expC5>
<expC5> is the name of the Foxpro table or cursor to return SQL Server data to.

<expC6>
<expC6> a value of 'dbf' will return SQL Server data to a Foxpro table. A value of 'cursor' will return SQL 	Server data to a Foxpro cursor.

<exp1>
<exp1> is usually the order by field you selected in <expC3>. FoxPro table key field record last 	retrieved for 	SQL Server table. Of course, you may use memory variables and arrays.  

Returns	Numeric 
		    < 0	error condition

Description:

Sends the next record from a SQL Server table to a Foxpro table or cursor. Use this function in your Foxpro edit screen for your next button. Important: If your order by field records have duplicate keys this function will skip like records. Usually, you would use this function on a unique SQL Server key field or data that you know will be unique.  

Example:

set library to fpsql                                 
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqlnext(h,'manf','test','empno','empno,first,last,address','newtable','cursor',empno)    && get next record                 
	<manf> name of database your table resides within SQL Server
	<test>   name of SQL Server table you would like next record from
	<empno> name of field of SQL Server table that you would like data ordered (by 			employee number)
	<empno,first,last,address> SQL Server table field list, you may use '*' for all fields
	<newtable> name of table or cursor that you would like SQL Server table data returned 			to.
	<'cursor'> return <newtable> as a cursor
	<empno> uses Foxpro table field named empno for last record read. 
		 
                
SQLPRIOR(<expN1>,<expC1>,<expC2>,<expC3>,<expC4>,<expC5>,<expC6>,<exp1)

<expN1>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like use.

<expC3>
<expC3> is the SQL Server table field name to order the data by.

<expC4>
<expC4> is the list of fields to return back to a Foxpro table or cursor.

<expC5>
<expC5> is the name of the Foxpro table or cursor to return SQL Server data to.

<expC6>
<expC6> a value of 'dbf' will return SQL Server data to a Foxpro table. A value of 'cursor' will return SQL 	Server data to a Foxpro cursor.

<exp1>
<exp1> is usually the order by field you selected in <expC3>. FoxPro table key field record last retrieved for 	SQL Server table. Of course, you may use memory variables and arrays.  

Returns	Numeric 
		    < 0	error condition

Description:

Sends the prior record from a SQL Server table to a Foxpro table or cursor. Use this function in your Foxpro edit screen for your next button. Important: If your order by field records have duplicate keys this function will skip like records. Usually, you would use this function on a unique SQL Server key fields or data that you know will be unique.  

Example:

set library to fpsql                                 
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqlprior(h,'manf','test','empno','empno,first,last,address','newtable','cursor',empno)    && get next record                 
	<manf> name of database your table resides within SQL Server
	<test>   name of SQL Server table you would like prior record from
	<empno> name of field of SQL Server table that you would like data ordered (by 			employee number)
	<empno,first,last,address> SQL Server table field list, you may use '*' for all fields
	<newtable> name of table or cursor that you would like SQL Server table data returned 			to.
	<'cursor'> return <newtable> as a cursor
	<empno> uses Foxpro table field named empno for last record read. 
		 
                
SQLDEL(<expN1>,<expC1>,<expC2>,<expC3>,<exp1>)

<expN1>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like use.

<expC3>
<expC3> is the SQL Server table field name to use for location of record.

<exp1>
<exp1> is usually the order by field you selected in <expC3>. FoxPro table key field record last retrieved from 	SQL Server table. Of course, you may use memory variables and arrays. Important: This will delete all 	records from SQL Server table that match the key value you supply. Usually you would delete records 	using the unique key field on SQL Server. 

Returns	Numeric 
		    < 0	error condition

Description:

Deletes all records in the SQL Server table using the key value <exp1> supplied. 

Example:

set library to fpsql                                 
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqldel(h,'manf','test','empno','empno,'12345')    && delete employee record 12345                  
	<manf> name of database your table resides within SQL Server
	<test>   name of SQL Server table you would like to delete record from
	<empno> name of field of SQL Server table that you would like data ordered (by 			employee number)
	<12345> key value for deletion. You may use field names, arrays and memory variables.
		 
                
SQLINSER(<expN1>,<expC1>,<expC2>,<expC3>)

<expN1>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like to insert records into.

<expC3>
<expC3> field list with values to insert into SQL Server table field name. Make sure your SQL Server table field names are spelled correctly case counts. If you have problems with your field list exceeding memory, break down your field list into multiple sqlinsert statements.

Returns	Numeric 
		    < 0	error condition


Description:

Inserts new record into SQL Server table. This function is very useful because you don't have to worry about building that horrendous insert statement for SQL Server. Use this for your Add button in you edit screens or just about anything.

Example:

set library to fpsql                                 
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqlinsert(h,'manf','test',"empno with '12345',first with m.first,address with address" )                   
	<manf> name of database your table resides within SQL Server
	<test>   name of SQL Server table you would like to delete record from
	<field list> empno with '12345'- empno is field name of SQL Server table and value  '12345' supplied 
		first with m.first - first is field name of SQL Server table and value to insert from m.first
		address with empno.address - address is field name of SQL Server table and empno.address is 			value from a Foxpro table field.
 
		 
                
SQLUPDATE(<expN1>,<expC1>,<expC2>,<expC3>,<expC4>,exp1)

<expN1>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like to update.

<expC3>
<expC3> field list with values to update the SQL Server table. Make sure your SQL Server table field names are spelled correctly case counts. If you have problems with your field list exceeding memory, break down your field list into multiple sqlupdate statements.

<expC4>
<expC4> is the SQL Server table field name used for locating the record for update.

<exp1>
<exp1> is the SQL Server table field name value used for locating record for update.

Returns	Numeric 
		    < 0	error condition

Description:

Updates existing record into SQL Server table. This function is very useful because you don't have to worry about building that horrendous update statement for SQL Server. Use this for your Change button in you edit screens or just about anything. Caution: Will update multiple records if they match <expC4> and <exp1>.

Example:

set library to fpsql                                 
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqlupdate(h,'manf','test',"first with m.first,address with address",'empno','12345' )                   
	<manf> name of database your table resides within SQL Server
	<test>   name of SQL Server table you would like to delete record from
	<field list> first with m.first - first is field name of SQL Server table and value to insert from m.first
		address with empno.address - address is field name of SQL Server table and empno.address is 			value from a Foxpro table field.
 	<empno> SQL Server field name for locating records for update
	<12345>  locate empno with 12345 as the value and update with field list.


                
SQLSEEK(<expN1>,<expC1>,<expC2>,<expC3>,exp1)

<expN1>
<expN> is the connection handle returned by DBConnect()

<expC1>
<expC1> is the name of the SQL Server database your table resides in.

<expC2>
<expC2> is the SQL Server table name you would like to update.

<expC3>
<expC3> is the SQL Server table field name to use for location of record.

<exp1>
<exp1> is the SQL Server table field name value used for locating record for seek.

Returns	Numeric 
		    < 0	error condition

Description:

Determines if record exists on SQL Server table. Useful if your adding to a table that is not a unique key field in SQL server. Can be used before you try to insert a record into SQL Server table.
 
Example:

set library to fpsql                                 
set library to foxtools additive             
h=dbconnect('datasource','sa','')          && get connection handle for SQL Server
err=sqlseek(h,'manf','test','empno','12345' )                   
	<manf> name of database your table resides within SQL Server
	<test>   name of SQL Server table you would like to delete record from
	<empno> SQL Server field name for locating records for insert
	<12345>  Check if empno 12345 is located in SQL Server table.


                

