Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQLServer- Identifier/ AutoInc value and CA
Message
 
 
À
01/06/2007 12:34:46
Aman Bains
Jaguar Computers
Jalandhar, Inde
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Database:
MS SQL Server
Divers
Thread ID:
01229802
Message ID:
01229843
Vues:
10
This message has been marked as the solution to the initial question of the thread.
>>Check Re: Auto Refresh Key fields after insert with CA Thread #1100805 Message #1101047
>
>The Message #956056 link in the above message is most complete & comprehensive. I have understood that the following needs to be done:-
>
>?"1) Refresh IDENTITY field using [SELECT @@IDENTITY] command"
>oCA.InsertCmdRefreshFieldList="f_IDENTITY"
>oCA.InsertCmdRefreshCmd="SELECT @@IDENTITY"
>
>
>Will that update my VFP cursor?
>
>I need some help with my class. I tried the following on CA class built using Mark E. McCasland's builder :-
>
>lAutoRefreshNewRecords= .T.
>lUseDefaultRefreshCmd= .F.
>
>cInsertCmdRefreshFieldList= acbalid
>
> _BuildDefaultRefreshCmd method as
>
>TEXT TO THIS.InsertCmdRefreshCmd TEXTMERGE NOSHOW PRETEXT 10
>	SELECT @@IDENTITY
>ENDTEXT
>
>
>The above in theory should work but I must have done something wrong. Any help from anyone is welcome.
>
>>There is also a nice article at http://www.foxclub.ru/articles/index.php?id=46#CursorAdapter, but unfortunately, in Russian.
>
>I wish my russian was better. :)

What exactly is not working? Was the new record correctly inserted?

As alternative, you may use AfterInsert method with the code from the article above:
PROCEDURE AfterInsert
LPARAMETERS cFldState, lForce, cInsertCmd, lResult
IF lResult=.T. && Insert was successful 
	LOCAL currentArea
	currentArea=SELECT()

	TRY
		IF 1=SQLEXEC(this.DataSource,"SELECT NewIdent=@@IDENTITY","NewIdent")
			REPLACE TabId WITH NewIdent.NewIdent IN (This.Alias)
			USE IN IDRes
		ELSE
			LOCAL laError(1)
			=AERROR(laError)
		ENDIF
	FINALLY
		SELECT (currentArea)
	ENDTRY
ENDIF
ENDPROC
This would work for VFP8 too.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform