|
You can use a simple class directly, inherit it or as a sample. A general ideas are:
* You create an object (for example "Access" named) of this class, insert it into container or use separately.
* All tables should be opened by USE method of ACCESS object. If a table is a DBF then an object just will close it in DESTROY event and it is not needed to close they manually. If a table is in SQL Server database then You should create a connection by SQLConnect or SQLStringConnect and pass it as third parameter.
* Find an each LOCATE, SCATTER, GATHER, REPLACE, GO TOP, BROWSE, INSERT commands in Your programs and replace they with calling of the same methods of ACCESS object with special rules.
* Inherit a class and create a methods equal to other direct access commands (SKIP, SEEK, ...) like we do it.
* If You develop your application and try to use a Pass-Through data access technology then our methods SELECTSQL and SENT_UPDATES will help You to use this technology with a DBF.
See a SAMPLE form to understand how it work. Shortly. A methods will do:
BROWSE
If a table - DBF then just browse. If a table is in SQL Server database then this method will create a temporary view with "FetchAsNeeded" property = .T. (for fast calling) if a local view was not created by LOCATE or GO_TOP method. If a local view exists then a method will run BROWSE commant with local view. See a "Browse" and "Refresh and Browse" buttons in SAMPLE.SCX
BROWSE_PREPARE
A BROWSE method call this method to locate an alias for browsing. You can use this method to create a recordsource for GRIDs.
CLOSE
Close a table opened by USE method.
CONTINUE
Used after LOCATE method. If a table is DBF then CONTINUE command will executed. If a table is in SQL Server database then a SKIP command will be executed for local view (result of LOCATE).
GATHER
If a table is DBF then GATHER ... MEMVAR ... command will be executed. If a local view for remote table was created by LOCATE, GO_TOP, BROWSE command and updatable then a GATHER ... MEMVAR ... command will be executed for local view. If a local view was not created then ERROR.
GET_LOCAL_ALIAS
Return a working alias: true alias for DBF or local view alias for remote table.
GET_TEMP_FILE
Generate, register and return an unique temporary file name. Will be removed in DESTROY.
GO_TOP
If a table - DBF then just GO TOP. If a table is in SQL Server database then this method will create a temporary view with "FetchAsNeeded" property = .T. (for fast calling) if a local view was not created by LOCATE or GO_TOP method. If a local view exists then a method will run GO TOP commant with local view.
INSERT
If a table is DBF then INSERT SQL command will be executed. If a local view for remote table was created by LOCATE, GO_TOP, BROWSE command and updatable then an INSERT SQL command will be executed for local view. If a local view was not created then INSERT command will be executed with SQLExec() function for remote table.
IS_UPDATABLE
Return .T. if an alias registered as DBF-table or a view is updatable.
LOCATE
If a table is DBF then just execute a LOCATE commant. When a table is in SQL Server then a SELECT command executed by SQLExec() function. A command will be converted by E_SQL_Select_Convert and E_SQL_Find_Variables function (EFoxSQL.FLL). For reference to variables You should use a ~m.VarName syntax. A LOCATE method will close a previous view and create a new view with result of searching. A view can be updatable. To make a view updatable You should pass a KeyFieldList parameter. Further a CONTINUE, GATHER, SCATTER, INSERT, BROWSE, GO_TOP methods can work with this view.
LOCATE_BF
Will create a local buffer if a table is in SQL Server ot DBF_Buffered property =.T. . Usefull for reference to related tables in BROWSE or ControlSource of objects. See "Browse Invoices" button in SAMPLE.SCX
REPLACE
If a table is DBF then REPLACE command will be executed. If a local view for remote table was created by LOCATE, GO_TOP, BROWSE command and updatable then a REPLACE command will be executed for local view. If a local view was not created then UPDATE ... WHERE ... command will be executed by SQLExec() function.
SCATTER
If a table is DBF then SCATTER .. MEMVAR ... command will be executed. If a local view for remote table was created by LOCATE, GO_TOP, BROWSE command and updatable then a SCATTER ... MEMVAR .. command will be executed for local view. If a local view was not created then ERROR.
SELECTSQL
Create a view. A view can be updatable. If a data selected from DBF then You can send updates to source just by SEND_UPDATES method.
SEND_UPDATES
Call this method in any cases when You want to send updates from view to source. If a source is a remote table and view is updatable then this method nothing do. When a source is DBF then You can send updates just by this method.
USE
Each tables should be opened by this method. If a table is a DBF then an object just will close it in DESTROY event and it is not needed to close they manually. If a table is in SQL Server database then You should create a connection by SQLConnect or SQLStringConnect and pass it as third parameter.
|