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:
01475356
Views:
22
>>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
>>
>
>One more question, please. I don't have the ? PROGRAM() line in my code. It is not necessary, right?

The lines with ? are for debugging only,
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform