Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting primary key when using CursorAdapter
Message
De
03/03/2006 21:50:08
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Getting primary key when using CursorAdapter
Divers
Thread ID:
01101462
Message ID:
01101462
Vues:
78
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.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform