VFP OleDB [examples]

You can use OleDB with the VFP OleDB driver if you need to work directly with existing VFP data. This works in desktop and cloud Apps.

OleDB is a COM technology so it is Windows-only. An ODBC driver for VFP can be downloaded from https://www.devart.com/odbc/

private oConn, oRS, m_count
oConn = createobject("ADODB.Connection")
oRS = createobject("ADODB.Recordset")
lcConnString = "Provider=vfpoledb;Data Source=C:\Temp\Northwind\northwind.dbc"
oconn.ConnectionString = lcConnString
oconn.Open()
oRS.Open("select * from customers where customerid='BOTTM'", oconn)
m_count = oRs.fields.count
// display the first record selected
for i=0 to m_count
    try
        ? "Name=" + oRS.Fields.item(i).Name + ",value=" + etos(oRS.Fields.item(i).Value)
    catch
        // ignore error from Memo
    endtry
endfor

Notice how you must use the item() method on the Fields property as this is exposed only as a property not a method.

The output produced is as follows:

Name=customerid,value=BOTTM
Name=companyname,value=Bottom-Dollar Markets                   
Name=contactname,value=Elizabeth Lincoln             
Name=contacttitle,value=Accounting Manager            
Name=address,value=23 Tsawassen Blvd.                                          
Name=city,value=Tsawassen      
Name=region,value=BC             
Name=postalcode,value=T2F 8M4   
Name=country,value=Canada         
Name=phone,value=(604) 555-4729          
Name=fax,value=(604) 555-3745  

Note: There is a known issue with retrieving memo fields using the VFP OleDB driver which is why TRY/CATCH to ignore the error.

https://www.lianja.com/doc/index.php/Working_with_OleDB


 

VFP migration

Q:

I have an existing project deployed in visual foxpro 5 and i was trying import project for Lianja. I downloaded linja trial for 30 days to make tests because my goal is putting the tables of project in a database so i think lianja could help me.
So i created an app in visual foxpro and imported my project for there but i can’t run the project to see the apllication. how can i do that?

A:

Information on Visual FoxPro imports and scripting can be found here: http://www.lianja.com/doc/index.php/…xPro_Scripting, including:

Importing Visual FoxPro Databases and Tables – http://www.lianja.com/doc/index.php/…ses_and_Tables
Importing Visual FoxPro Files – http://www.lianja.com/doc/index.php/…l_FoxPro_Files

Imports of Visual FoxPro projects, classes and forms extract the data from the VFP tables and generate source code scripts in your App. Start from the Lianja/VFP Command Window in the Console Workspace and run your scripts using DO or DO FORM and issue any required SET CLASSLIB or SET PROCEDURE commands to reference libraries.

Check the Error and Log windows in the Console Workspace for any issues. Your scripts can be edited in the Apps Workspace.

Form scripts (*.scp) can also be referenced from a Page (Pages Workspace -> Form Tools -> Page), in which case they are embedded in a full-Page sized VFP Custom Section in your App. To modify the Custom Section, edit the Form script on which it is based, to add other Pages to the App, use any of the wide range of Lianja in-built Sections.

After using the dbc importer, you will have a Lianja database with your tables and production indexes. You can then access these from the Data Workspace, using OPEN DATABASE, SQL statements and USE and other NoSQL commands from the Console, from scripts and programs or using drag and drop and attribute assignment in standard Lianja sections.

Note that it is recommended to rebuild your forms using the Lianja visual Page Builder and drag ‘n’ drop Lianja standard sections and combine these with your existing VFP background business logic code. This, along with being the easiest and quickest way to migrate – providing you write the client event delegates in JavaScript (with Lianja/VFP extensions) – will have the added advantage that you will also be able to run your Lianja Apps on web or mobile devices.

You will see the source code for your imported project files in the Files explorer in the Apps workspace with your App open. Source from forms will have a .scp extension, source from class libraries a .vcp extension, .prg files remain unchanged.

You can then run the scripts/programs, edit the scripts, and embed in a Page if required.


Today user expectations from applications are very different from those VFP days.
Because of the technology gap I am afraid there is no free lunch in the migration.

Lianja is “cross” on so many levels (Win/Mac/Linux , LAN/internet/Cloud, desktop/web/mobile…)
Choosing among standard sections, custom sections and canvas sections…
VFP/JavaScript/PHP/Python…
Lianja is huge. “Cross…” and “multi” are a plus, but in the same time it is a problem – because of all complexity.

Is Lianja for you – it is a tough question. You need to know where you are headed with your apps.
I suggest you read more about Lianja concept: http://www.lianja.com/community/show…Lianja-concept

VFP apps need to be broken down to smaller pieces and to be rearranged a lot for today modern technologies:
App Center (and Categories winthin) -> Apps -> Pages (and Page centers) -> Sections as visual representation of SQL tables
What about strict separation of server side computing from the client side computing in our old VFP apps?
That is why I do not believe in easy importing on button click.
Do not expect that you will automatically get GUI responsiveness and all to work in web browsers and mobile.

Starting from scratch, at least, we can use VFP syntax knowledge in delegates and progress step by step in converting our apps.
Your VFP knowledge are very valuable and useful here, unlike in some other alternatives where you need to learn completlly new syntax.

Advice? Do begin with some small part of your complex app and see how are you doing.


The (single) most important document you should read before you start developing Apps in Lianja.

VFP vs. JavaScript

For developers with VFP background:

Building Lianja web/mobile apps means you have to learn some JS to write client side stuff, because VFP is used only on server side. Web browsers do not speak Visual Foxpro but understand JavaScript .

VFP is data centric. Plain SQL commands are the part of VFP syntax. That is why VFP developers can make anything with data what customer wants, and so quickly. These complex data apps are tedious to convert to some newer platform. That is why VFP belongs to server side in Lianja concept.

vfp2js_1

vfp2js_2

vfp2js_3

vfp2js_4

vfp2js_5

vfp2js_6

vfp2js_7

vfp2js_8

vfp2js_9

vfp2js_10

vfp2js_11

vfp2js_12

vfp2js_13

Source: http://www.slideshare.net/wmichaelfeltman/feltman-js4-vfp