No return of identity when using INSERT sql on TMSQuery.

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Guest

No return of identity when using INSERT sql on TMSQuery.

Post by Guest » Mon 07 Feb 2005 20:29

How can I get the value of the identity column to my TMSQuery dataset after an insert ?
I'm using the TMSQuery component with an insert sql (generated).
(when I remove the insert sql and let SDAC do it automatically it works fine)

I also tried the returnparams and queryidentity options, but that did not help.

SDAC trial version 3.50.0.11 ( win32 delphi 2005 ) Sql2000

CREATE TABLE [dbo].[parts] (
[part] [int] IDENTITY (1, 1) NOT NULL ,
[description] [varchar] (100) NOT NULL
) ON [PRIMARY]
GO

TMSQuery : Select = select part, description from parts

TMSQuery : insert sql = INSERT INTO parts (description) VALUES (:2)
SET :1 = SCOPE_IDENTITY()

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 08 Feb 2005 16:17

In this case you need to write BeforeUpdateExecute handler and set in it ParamType := ptInputOutput for corresponding parameter.

Guest

Post by Guest » Tue 08 Feb 2005 18:29

Thanks for the help, it works.

Post Reply