xsharp.eu • Remote views, VFP database container (.dbc) and database connections
Page 1 of 1

Remote views, VFP database container (.dbc) and database connections

Posted: Thu Feb 25, 2021 3:42 am
by RajNZ
Hi,

Sorry if this is answered elsewhere, but I haven't found a document covering this area.

An important part of making X# feasible for converting our large VFP project is support for :
Remote views
VFP database container (.dbc) to hold the remote views (or some alternative)
Database connections, defined in the .dbc to hold the connection string etc that the views are based on (or some alternative)

For example :
open database xyz
set database to xyz
create connection myconn ... connstring "Driver=SQL Server;Server= etc" ...
create sql view myview remote connection myconn as select * from mytable
use myview
...do stuff with myview, including writing with row and table buffering...
use in myview

Would also be great if tableupdate() and tablerevert() are supported, but even just immediate writes might be fine.

While it would be possible to use SQLStringConnect() and sqlexec() instead of remote views, that would involve a great deal of re-coding in VFP and would make an X# conversion impractical at that point.

Could someone please point me to a document that might cover this, or an entry in the roadmap that either includes or excludes support for these concepts?

Thanks.
Paul

Remote views, VFP database container (.dbc) and database connections

Posted: Thu Feb 25, 2021 6:30 am
by robert
Paul,
This is indeed not supported yet.
Can you create a small example against the Sql Server Northwind database that shows how you are using this ?

Robert

Remote views, VFP database container (.dbc) and database connections

Posted: Thu Feb 25, 2021 10:04 pm
by RajNZ
Hi,

A simple example would be this :

Code: Select all

*** It is assumed that the Northwind VFP database has already been created.
*** The following 2 lines would be executed once near the start of the application.
open database Northwind
set database to Northwind
*** The following 2 lines would be executed as needed, whenever changing between back-end databases.
create connection myconn  connstring "Driver=SQL Server;Server= etc..."
create sql view OrdersView remote connection myconn as select * from Orders where OrderID = ?InputOrderID

*** Fetch the details for order 10248 into a cursor with an alias of CurrentOrder.
local InputOrderID
InputOrderID = "10248"
use OrdersView in 0 alias CurrentOrder
*** Update the shipping address.
replace CurrentOrder.ShipAddress with "my new address" in CurrentOrder
*** Could execute a TableUpdate() now to explicitly commit the data, or simply rely on the automatic commit whenever the row is navigated away from or the cursor is closed.
use in CurrentOrder

Remote views, VFP database container (.dbc) and database connections

Posted: Fri Feb 26, 2021 8:31 am
by robert
Paul,
Thanks for the example.
I tried this here and the update was not sent to the server.

I checked the FoxPro docs, and after adding DBSETPROP("OrdersView","VIEW","SendUpdates",.t.) then indeed the changes were sent back to the server.

Robert