Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Files for ServerComputer
Message
From
25/08/2023 14:26:08
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01686954
Message ID:
01686984
Views:
46
>>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.

OMG! I really didn't think it was possible! If I knew it was, way before, my hair wouldn't be as white as it is now! :)

Thank you for your great help!
Previous
Reply
Map
View

Click here to load this message in the networking platform