Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Retrieve autoincrement value from SQL server remote view
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00550467
Message ID:
00550474
Vues:
32
>In VFP 6.0 code, I need to add a record to a remote view of a table in an
>SQL Server data source. The id number for this table is an auto-increment
>column and is the key field. I then need to be able to find out what value was put in the
>auto-incremented column so I can use it when adding a record to a
>second table.
>
>I can't figure out how to read the value created by the auto increment. It
>doesn't seem to show up until I close the view and reopen it which takes too
>long on this 25 K record file. The Refresh() function can't work on buffered
>records or tables. Remote views must be buffered so I can't use refresh().
>
>What am I missing?
>tia for any ideas.

Using SPT, you can issue a call to the backend server like the following:

sqlexec(curgetprop("ConnectHandle","MyRemoteView"),"select @@identity","c_ident")

The last identify value created by SQL Server on that connection will be available in the c_ident cursor. You can use this value and put it into the remote view or use it as is.

Note: If you know you have no triggers updating any other tables with identity columns, this works. If you do, then you will get the identity value of the trigger tables and not the initial one.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform