Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Understanding CursorAdapter methods
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01475311
Message ID:
01475420
Vues:
22
For the Generic class do not use CS, but for the instances, use it.


>>>One thing that I would like is NOT to have to populate the CursorSchema property. Is it possible? What would I need to change in your example to make it work without CursorSchema?
>>
>>
>> oCA=CREATEOBJECT("CA_SCOPE_IDENTITY")    
>>   BROWSE NORMAL
>>   IF TABLEUPDATE(1, .t.)
>>       BROWSE NORMAL
>>   ELSE
>>      AERROR(aaa)
>>      MessageBox(aaa[2])
>>   ENDIF
>>
>>
>>DEFINE CLASS CA_SCOPE_IDENTITY AS CursorAdapter 
>>     DataSourceType = [ADO]
>>     Alias = "cTest"
>>     BufferModeOverride = 5
>>     SelectCmd = "select * from TestTable"
>>*******     CursorSchema="Id I, name Varchar(20)"
>>*******     UseCursorSchema= .T.    
>>     Tables = "Dostav"
>>     UpdatableFieldList="name, BulStat, Address"
>>     UpdateNameList="Id TestTable.Id, name TestTable.Name"
>>     KeyFieldList="Id"  
>>     AutoUpdate = "Id"
>> 
>>     PROCEDURE Init
>>        LOCAL nAutoRefreshConn AS ADODB.Connection
>>        nAutoRefreshConn=CREATEOBJECT([ADODB.Connection])
>>        nAutoRefreshConn.ConnectionString = [Provider=SQLNCLI;Server=(local);Database=TestDB;Trusted_Connection=yes;]
>>        nAutoRefreshConn.Open()
>>
>>        nCommand =CREATEOBJECT([ADODB.Command])
>>        nCommand.ActiveConnection = nAutoRefreshConn
>>        nRS =CREATEOBJECT([ADODB.RecordSet])
>>        nRS.ActiveConnection = nAutoRefreshConn
>>        this.DataSource = nRS
>>
>>        this.UpdateCmdDataSourceType = [ADO]
>>        this.InsertCmdDataSourceType = [ADO]
>>        this.DeleteCmdDataSourceType = [ADO]
>>        
>>        this.UpdateCmdDataSource = nCommand
>>        this.InsertCmdDataSource = nCommand
>>        this.DeleteCmdDataSource = nCommand
>>        
>>*******        IF NOT this.CursorFill(.t.,.f.,0, nCommand)
>>        IF NOT this.CursorFill(.f.,.f.,0, nCommand)
>>           AERROR(aaa)
>>           MessageBox(aaa[2])
>>        ENDIF
>>     ENDPROC
>> 
>> 
>>    PROCEDURE BeforeInsert(cFldState, lForce, cInsertCmd)
>>
>>            IF LEN(ALLTRIM(this.AutoUpdate))>0  
>>                cInsertCmd = cInsertCmd + ;  
>>                    "; DECLARE @id int; SELECT @id = SCOPE_IDENTITY()" + ;  
>>                    "; EXEC Get_ValHelper @id, ?@" + ;  
>>                    this.Alias + "." + ALLTRIM(this.AutoUpdate)+ " OUTPUT" && In ADO the OUTPUT here is mandatory.
>>            ENDIF  
>>    ENDPROC     
>>ENDDEFINE
>>
>>But better work with CursorSchema
>
>Thank you. The reason I would like my CA to work without CursorSchema is I am trying to make my class generic and having to provide CursorSchema makes it difficult (not sure if impossible though).
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