Page 1 of 1

Dataset Identify Fields

Posted: Tue 05 Feb 2008 12:54
by FaNIX
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]

Posted: Tue 05 Feb 2008 15:56
by Antaeus
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.