Need assistance with fpODBC

Kenneth Brody kenbrody at spamcop.net
Tue Oct 23 11:00:57 PDT 2012


On 10/23/2012 10:56 AM, Rick Hane wrote:
> Hi Rich,
>
> I think I was not clear in my email.  Of course fp reads Excel files via
> import.  That is the step I want to remove.
>
> I want to set up the fpODBC to read the data directly from the SQL data
> base.  I know this is possible.  The problem is how.
[...]

Since you say you only need to import the data, rather than have "live" 
access to it, you can use a simple low-level ODBC query to get the data and 
import it into filePro.

Basically:

Establish the connection:

     handle = new odbc_connection( DSN )

(You need to determine the appropriate DSN to connect to your SQL database.)

(Check for a positive "handle" value, to make sure it succeeded.)

Create a query handle:

     qhandle = new odbc(handle)

(Check for a positive handle value, to make sure it succeeded.)

Query the database:

     odbc qhandle query "select * from mytable"

(Adjust the query as appropriate, including a possible "where" clause.)

(Check for a null @odbcerror["1"], to make sure it succeeded.)

Use the @odbc.qhandle[] array to access the fields, and post as appropriate.

Scroll through the records using:

     odbc qhandle getnext

and use @odbc.qhandle.eof[] to test for end-of-file.

-- 
Kenneth Brody


More information about the Filepro-list mailing list