Hooking up to a Visual Foxpro db ?

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bonbon
Posts: 62
Joined: Thu Jul 17, 2008 11:48 pm

Hooking up to a Visual Foxpro db ?

Post by bonbon » Thu Mar 12, 2009 11:23 pm

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

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Fri Mar 13, 2009 2:57 am

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.

bonbon
Posts: 62
Joined: Thu Jul 17, 2008 11:48 pm

Post by bonbon » Fri Mar 13, 2009 9:12 am

That's done the trick ! I'm getting some data through now. (Version 3.0, by the way.) Thanks for that.

Pete

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Fri Mar 13, 2009 11:43 pm

Glad it worked. Cheers.

Post Reply