Check
Re: Auto Refresh Key fields after insert with CA Thread #
1100805 Message #
1101047>I had to switch to the CursorAdapter approach and there is one issue I haven't resolved. Basically, it is in regards to when doing the insert. I have the following code which I use for all SQL commands:
>
>
> loConnection=CREATEOBJECT('ADODB.Connection')
> loConnection.Open(This.cSQLStringConnect)
> loCommand=CREATEOBJECT('ADODB.Command')
> loCursor=CREATEOBJECT('CursorAdapter')
> loCursor.Alias='SQLExecTemp2'+GeneratePwd(20)
> loCursor.DataSourceType='ADO'
> loCursor.DataSource=CREATEOBJECT('ADODB.RecordSet')
> loCursor.SelectCmd=This.cSQL
> loCursor.DataSource.ActiveConnection=loConnection
> loCommand.ActiveConnection=loConnection
> loCursor.CursorFill(.F.,.F.,0,loCommand)
>
> * Dump everything into the required cursor
> IF UPPER(This.cSQL)='SELECT'
> SELECT * FROM (loCursor.Alias) INTO CURSOR (lcCursor)
> ENDIF
>
>
>But, when this is an INSERT, I do not know how to get the primary key value of the record which was inserted. Those primary key fields have all AutoInc ON. So, the INSERT works well. But, I need to find a way, after the loCursor.CursorFill() line to get back at that record so I can know which primary key value was assigned.
--sb--