o = NEWOBJECT("sqlPass", "sqlPass.prg") ?o.sqlConnect("N11416GE", "northwind", "sa", "") && don't use blank passwords! ;-) ?o.sqlSelect("SELECT * FROM customers",, 5) && 5 = optimistic table buffering *-- at this point, we have an SPT cursor that is updatable and that behaves *-- almost like a regular VFP local view. *-- The only exception is REQUERY() which doesn't work with SPT cursors. *-- The wrapper takes care of that (see below). *-- change some data REPLACE ALL companyName WITH "x" + ALLTRIM(companyName) ?TABLEUPDATE(.t.) ?o.Requery() BROWSE *-- revert the changes REPLACE ALL companyName WITH SUBSTR(companyName, 2) ?TABLEUPDATE(.t.) ?o.Requery() BROWSE *-- the following sample shows how to use parameterized views lcCompanyId = "ALFKI" ?o.sqlSelect("SELECT * FROM customers WHERE customerId=?lcCustomerId",, 5) && 5 = optimistic table buffering BROWSE lcCompanyId = "ANTON" ?o.Requery() BROWSE *-- the wrapper keeps track of all the SPT cursors. This allows you to open other views. ?o.sqlSelect("SELECT * FROM orders WHERE customerid=?lcCustomerId",, 5) BROWSE lcCustomerId="ALFKI" ?o.Requery() BROWSE SELECT customers ?o.Requery() BROWSEDragan,
o = NEWOBJECT("sqlPass", "sqlPass.prg") ?o.sqlConnect("N11416GE", "northwind", "sa", "") && don't use blank passwords! ;-) ?o.sqlSelect("SELECT * FROM customers",, 5) && 5 = optimistic table buffering *-- at this point, we have an SPT cursor that is updatable and that behaves *-- almost like a regular VFP local view. *-- The only exception is REQUERY() which doesn't work with SPT cursors. *-- The wrapper takes care of that (see below). *-- change some data REPLACE ALL companyName WITH "x" + ALLTRIM(companyName) ?TABLEUPDATE(.t.) ?o.Requery() BROWSE *-- revert the changes REPLACE ALL companyName WITH SUBSTR(companyName, 2) ?TABLEUPDATE(.t.) ?o.Requery() BROWSE *-- the following sample shows how to use parameterized views lcCompanyId = "ALFKI" ?o.sqlSelect("SELECT * FROM customers WHERE customerId=?lcCustomerId",, 5) && 5 = optimistic table buffering BROWSE lcCompanyId = "ANTON" ?o.Requery() BROWSE *-- the wrapper keeps track of all the SPT cursors. This allows you to open other views. ?o.sqlSelect("SELECT * FROM orders WHERE customerid=?lcCustomerId",, 5) BROWSE lcCustomerId="ALFKI" ?o.Requery() BROWSE SELECT customers ?o.Requery() BROWSEHTH