Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding CursorAdapter methods
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01475311
Message ID:
01475410
Views:
36
>>>I should have noticed it way earlier but I just did. When I check your code in the BeforeInsert the variable cInsertCmd has both the "INSERT INTO ....." expression and the "DECLARE..." expression, as they should be.
>>>
>>>When I review the value in my variable (in my program) cInsertCmd the "INSERT INTO... " expression is missing. The only thing I see in my code is the "DECLARE..." part. And my code in the BeforeInsert is identical to yours. Can you think of anything that makes my CA code not passing the INSERT INTO value in the method BeforeInsert()?
>>
>>
>>Could you script the class with Class Browser and post it here?
>
>Keep in mind that I am using ADO and you used ODBC in your example. I don't know if it makes a difference or not though.

You should start with that :-))))
   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)
           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
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform