Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting primary key when using CursorAdapter
Message
From
03/03/2006 21:50:08
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Getting primary key when using CursorAdapter
Miscellaneous
Thread ID:
01101462
Message ID:
01101462
Views:
77
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
Next
Reply
Map
View

Click here to load this message in the networking platform