Page 1 of 1

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

Posted: Tue 02 Feb 2010 16:56
by dartas
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.

Posted: Wed 03 Feb 2010 08:14
by dartas
I forgot to type what error occuring:
"Operand type clash: numeric is incompatible with uniqueidentifier"

Posted: Wed 03 Feb 2010 10:10
by Dimon
SQL server doesn't allow this functionality. You should refresh a table to solve the problem.

Posted: Wed 03 Feb 2010 12:24
by dartas
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

???

Posted: Thu 04 Feb 2010 09:03
by Dimon
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.

Posted: Thu 04 Feb 2010 12:53
by dartas
Thank you.