Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Files for ServerComputer
Message
 
À
24/08/2023 15:39:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01686954
Message ID:
01686978
Vues:
67
>I don't see a big improvement on CursorAdapters over remote views besides not using a DBC. If CAs would allow me to use data disconnected, that would be a big improvement, say, connect, get data, disconnect, manipulate data, connect, save manipulated data and then disconnect. Is that possible with CAs? On the contrary, remote views have to be connected from when they are opened until they are closed.

It is possible:
LOCAL lcTest AS crsNch
lcTest = CREATEOBJECT([crsNch])
IF NOT lcTest.FillCursor()
   MESSAGEBOX(lcTest.SQLError)
   RETURN
ENDIF
BROWSE NORMAL
** Do Some changes
IF NOT lcTest.UpdateCursor()
   MESSAGEBOX(lcTest.SQLError)
   RETURN
ENDIF
USE





DEFINE CLASS crsNch AS CursorAdapter
    Alias              = "crsTest"
    BufferModeOverride = 5
    DataSourceType     = "ODBC" 
    ConnectionString   = "Driver={SQL Server};Server=ServerNameHere;Trusted_Connection=yes;DataBase=DataBaseNameHere;"
    DataSource         = 0
    SQLError           = []
    KeyFieldList       = "Key Field Name hare"
    SendUpdates        = .t.
    WhereType          = 1
    Tables             = "TableNameHer"

    PROCEDURE Init
        TEXT TO this.UpdatableFieldList NOSHOW  PRETEXT 15
             KOD, NAME
        ENDTEXT

        TEXT TO this.UpdateNameList NOSHOW  PRETEXT 15
             KOD      TableNameHere.KOD,
             NAME     TableNameHere.NAME
        ENDTEXT
        this.SelectCmd = [SELECT Kod, Name FROM TableNameHere]
    ENDPROC

    PROCEDURE FillCursor
         LOCAL laError[1]
         this.DataSource = SQLSTRINGCONNECT(this.ConnectionString)
         IF this.DataSource < 0
            AERROR(laError)
            this.SQLError = laError[1,2]
            RETURN .f.
         ENDIF
         IF NOT this.CursorFill()
            AERROR(laError)
            this.SQLError = laError[1,2]
            RETURN .f.
         ENDIF
         SQLDISCONNECT(this.DataSource)
    ENDPROC

    PROCEDURE UpdateCursor
         LOCAL laError[1]
         this.DataSource = SQLSTRINGCONNECT(this.ConnectionString)
         IF this.DataSource < 0
            AERROR(laError)
            this.SQLError = laError[1,2]
            RETURN .f.
         ENDIF
         IF NOT TABLEUPDATE(1,.t.,this.Alias)
            AERROR(laError)
            this.SQLError = laError[1,2]
            RETURN .f.
         ENDIF
         SQLDISCONNECT(this.DataSource)
    ENDPROC
ENDDEFINE
BTW with CAs you can use not only ODBC but ADO too.
So you may have one application that can use RDBMS like SQL Server and DBFs w/o many cnahges.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform