Dataset Identify Fields

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
FaNIX
Posts: 6
Joined: Sat 19 Jan 2008 13:22
Location: pretoria

Dataset Identify Fields

Post by FaNIX » Tue 05 Feb 2008 12:54

I'm using SDAC 4.35, and was wondering if something like this is possible:

I have a Table, where the primary key is a auto increment datatype(Identity). Is it possible to populate that field in a dataset when the .insert method is called? I want the value to be know in my code, because doing the .post. I know this was possible with Firebird DB, maybe these components have something similar? Please help...

Code: Select all

CREATE TABLE [dbo].[Patient_Status](
	[Patient_Status_Entry_ID] [int] IDENTITY(1,1) NOT NULL,
	[Patient_Entry_ID] [int] NOT NULL,
	[Status_Description] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Patient_Status_Date] [datetime] NULL,
 CONSTRAINT [PK_Patient_Status] PRIMARY KEY CLUSTERED 
(
	[Patient_Status_Entry_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 05 Feb 2008 15:56

Values for IDENTITY fields are generated after posting a record.

In order to obtain identity field value after post automatically, you should enable the DMLRefresh option.

If you want to insert a value into an IDENTITY field manually, you should enable the IDENTITY_INSERT option for the table containing this field.
The IDENTITY_INSERT option is described in SQL Server Book Online.

Post Reply