Using FileMaker as ODBC Source

Bob Sneidar bobsneidar at iotecdigital.com
Tue Sep 15 11:51:38 EDT 2015


I found using Livecode cursors so frustrating I almost gave up on using LC for database driven projects. That is until I came across sqlYoga, by Blue Mango Learning, Trevor Devore's but of genius. This will return a numbered array of the query results. Much easier to work with. 

Cursors are read only, so you have to programmatically build an insert/update statement from scratch. That is a lot of coding. sqlYoga has a record object method that allows you to modify the columns for a record object and then insert/update the database. 

Others have produced very capable SQL API's for Livecode, MagicSQL by Peter Hayworth comes to mind, and my suggestion would be, unless you want to write a new API yourself, and then debug it for the next few months, you may want to pony up a little cash and purchase one of these. You will find database development much eased. 

Bob S


> On Sep 14, 2015, at 21:35 , Javier Miranda <jemirandav at gmail.com> wrote:
> 
> Hi friends, can you take a look to this code please? 
> 
> on mouseUp
>   put "ODBC" into theDBType 
>   put "localhost" into theDBHost
>   put "SACyV" into theDBName
>   put "Admin" into theDBUser
>   put  “bcdea" into theDBPassword
>   put revOpenDatabase( theDBType, theDBName , theDBHost, theDBUser, theDBPassword ) into theConnectionID
>   put revQueryDatabase( theConnectionID, "SELECT * FROM Almacen") into theCursor
>   revMoveToLastRecord theCursor
>   --put the result  (It puts false in the msg)
>   put revCurrentRecord(theCursor) + 1 into field RegAct
>   put revDatabaseColumnNamed(theCursor, TotRec) & return & Total into field RegNum
>   set the endValue of Scrollbar Marcador to revCurrentRecord(theCursor) + 1
>   set the  thumbposition of Scrollbar Marcador to 1
>   put revDatabaseColumnNamed(theCursor, ItemID) into field ItemID
>   put revDatabaseColumnNamed(theCursor, Producto) into field Producto
>   put revDatabaseColumnNamed(theCursor, Marca) into field Marca
> end mouseUp
> 
> It successfully establishes a connection to a datasource (A FileMaker 13 database), makes SQL query, put some values into certain fields in the card and put the fields of the record in the corresponding cards fields.
> The problem is doesn’t “like” revMoveToLastRecord theCursor.
> I tried to use these commands To navigate the records in the result set:
> - revMoveToFirstRecord <cursor id>
> - revMoveToPreviousRecord <cursor id>
> - revMoveToNextRecord <cursor id>
> - revMoveToLastRecord <cursor id>
> But none of them seems to work. Is this a limitation of the ODBC driver? And  if it is, what have to be done to navigate the records in the cursor?
> Saludos,
> Javier
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list