How to return a Guid value after insert from the server?

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dartas
Posts: 18
Joined: Mon 12 Jan 2009 14:40

How to return a Guid value after insert from the server?

Post by dartas » Tue 02 Feb 2010 16:56

Hello,

In one table I'm trying to change primary key field instead of AutoInc to Guid. On insert Guid field is generating on the server. The problem is that I do not find how to return the inserted Guid. With AutoInc everything is working well.

dartas
Posts: 18
Joined: Mon 12 Jan 2009 14:40

Post by dartas » Wed 03 Feb 2010 08:14

I forgot to type what error occuring:
"Operand type clash: numeric is incompatible with uniqueidentifier"

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 03 Feb 2010 10:10

SQL server doesn't allow this functionality. You should refresh a table to solve the problem.

dartas
Posts: 18
Joined: Mon 12 Jan 2009 14:40

Post by dartas » Wed 03 Feb 2010 12:24

If I understad where is one way:

1. Generate Guid on clinet side
2. Insert
3. Refresh
4. Use Locate to find and set cursor on inserted record

???

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 04 Feb 2010 09:03

If you generate GUID on client side, you don't need to refresh dataset and to find inserted record, because after inserting cursor is located on this record.

dartas
Posts: 18
Joined: Mon 12 Jan 2009 14:40

Post by dartas » Thu 04 Feb 2010 12:53

Thank you.

Post Reply