Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting primary key when using CursorAdapter
Message
 
 
À
03/03/2006 21:50:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01101462
Message ID:
01101466
Vues:
10
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform