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:
01475366
Vues:
22
Yes, I saw it later. So I do have this property and it is not causing the problem. But something else does :)

>That is a custom property. There you put the identity field :-)
>
>It is in place of Aleksey's IDENTITY_Field property :-)
>
>
>
>
>>>This works for me:
>>>
>>>
>>>nAutoRefreshConn=SQLSTRINGCONNECT("DRIVER=SQL Server;SERVER=(local);Trusted_Connection=Yes;DataBase=TestDB")
>>>
>>>IF nAutoRefreshConn > 0
>>>   oCA=CREATEOBJECT("CA_SCOPE_IDENTITY")    
>>>   oCA.DataSource = nAutoRefreshConn
>>>   IF oCA.CursorFill(.t.)
>>>      BROWSE NORMAL
>>>      IF TABLEUPDATE(1, .t.)
>>>          BROWSE NORMAL
>>>      ELSE
>>>         AERROR(aaa)
>>>         MessageBox(aaa[2])
>>>      ENDIF
>>>   ELSE
>>>      AERROR(aaa)
>>>      MessageBox(aaa[2])
>>>   ENDIF
>>>ENDIF
>>>
>>>
>>>DEFINE CLASS CA_SCOPE_IDENTITY AS CursorAdapter 
>>>     DataSourceType = [ODBC]
>>>     Alias = "cTest"
>>>     BufferModeOverride = 5
>>>     SelectCmd = "select * from TestTable"
>>>     CursorSchema="Id I, name Varchar(20)"
>>>     UseCursorSchema= .T.    
>>>     Tables = "TestTable"
>>>     UpdatableFieldList="name"
>>>     UpdateNameList="Id TestTable.Id, name TestTable.Name"
>>>     KeyFieldList="Id"  
>>>     AutoUpdate = "Id"
>>> 
>>> 
>>>    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)  
>>>            ENDIF  
>>>            ?    
>>>            ? PROGRAM()    
>>>            ? "cInsertCmd=",cInsertCmd    
>>>    ENDPROC     
>>>ENDDEFINE
>>>
>>>
>>>
>>>In SQL Server:
>>>
>>>CREATE DATABASE TestDB
>>>GO
>>>USE TestDB
>>>GO
>>>CREATE TABLE TestTable (Id int IDENTITY(1,1), Name varchar(20))
>>>GO
>>>create procedure Get_ValHelper 
>>>(
>>>@in Int,
>>>@out int OUTPUT
>>>)
>>>AS 
>>> BEGIN
>>>    SET NOCOUNT ON
>>>    SET @out = @in
>>> END
>>>GO
>>>
>>
>>I noticed that you have property AutoUpdate. I can't find it in the VFP help on CA. Could this be the cause of my problem?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform