Page 1 of 1

Hooking up to a Visual Foxpro db ?

Posted: Thu Mar 12, 2009 11:23 pm
by bonbon
I'm trying to use a native Alpha5 database. I have set up an ODBC datasource, using the Microsoft Visual Foxpro driver (which I think is the correct one; to verify, I linked to this ODBC from Alpha5, and it worked).

In preOpenCard, I have put:

Code: Select all

 put revOpenDatabase("odbc","Copy of Names and Addresses",,,,,,) into tConID
   if tConID is "" then
      answer warning "Problem accessing database"
   end if
   put tConID into gConID
 
Then we have:

Code: Select all

   put "SELECT * FROM names;" into dbQuery

   put revQueryDatabase(gConID, dbQuery) into curID
   if curID is not a number then
      answer error "Query failed:" & cr & curID
      exit refreshTitleList
   end if

   answer "so far so good..."

   put revNumberOfRecords(curID) into recNum
   put revDatabaseColumnCount(curID) into colNum

   answer "recNum: " & recNum & "; colNum:" & colNum
This results in:

so far so good...
recNum: -1; colNum: 38

So it seems to have opened the table, and it knows how many columns are there, but it's not returning any rows. (There are plenty of rows, honest).

Any suggestions as to what I'm doing wrong or missing ?

Many thanks,

Pete

Posted: Fri Mar 13, 2009 2:57 am
by mwieder
What version of rev are you using for this? I haven't tried dealing with FoxPro in a while, but I had similar problems trying to do this with MSAccess, so your Microsoft experience may be similar. The rev ODBC driver wasn't able to deal with revNumberOfRecords() and always returned -1 for me. Obviously this wasn't going to work, so I resorted to

SELECT COUNT(*)

instead. See if that gets you by.

Posted: Fri Mar 13, 2009 9:12 am
by bonbon
That's done the trick ! I'm getting some data through now. (Version 3.0, by the way.) Thanks for that.

Pete

Posted: Fri Mar 13, 2009 11:43 pm
by mwieder
Glad it worked. Cheers.