How can understand that a Field is AutoIncrement Field?

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Murat

How can understand that a Field is AutoIncrement Field?

Post by Murat » Wed 23 Mar 2005 16:32

I have a table on MS SQL SERVER, and table has a autoincrement field that s name is 'ID'. I open with clientdaset this table, but i can not understand ID Field is AutoIncrement or not.

I must define Field is AutoIncrement because i do some job about field type automatically. How can i understand that a field is autoincrement or not?

Thanks.

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

Post by Ikar » Thu 24 Mar 2005 09:45

For autoinc fields Field.AutoGenerateValue = arAutoInc is set.

Guest

Post by Guest » Thu 24 Mar 2005 14:02

Ikar wrote:For autoinc fields Field.AutoGenerateValue = arAutoInc is set.
hi, I think i can not explain exactly what i mean.

Follow Steps

1. Create A Table
CREATE TABLE [dbo].[Table_Inc] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[NAMA] [varchar] (50) COLLATE Turkish_CI_AS NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Table_Inc] WITH NOCHECK ADD
CONSTRAINT [PK_Table_Inc] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO

2.Create a Application
3.Drop a TSQLConnection, and connect to sql (with core dbexpress)
4.Drop TSQLQuery and set connection property
5.Drop TDatasetProvider, set DataSet property, set AllowCommandText True
6.Drop TClientDataSet, set providername property,
7. set Clientdataset CommandText as "SELECT * FROM Table_Inc"
8. set Active as True
9.Open Clientdataset Fieldeditor
10.Click Add All Fields

and when i look ID Field, ID Field's AutoGenerateValue property is arNone. And ID Field type is TIntegerField. Read Only property is false.

In normal, ID Field must be AutoIncField, and Reada only is true.

I want to learn this fields is auto increment or not?

Thanks

Murat Ak

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

Post by Ikar » Fri 25 Mar 2005 10:27

Sorry, it is my mistake. On using DbxSda it is impossible to retrieve information about AutoInc-fields.

99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

Post by 99Percent » Mon 17 Oct 2005 13:36

Ikar wrote:Sorry, it is my mistake. On using DbxSda it is impossible to retrieve information about AutoInc-fields.
How do you use autoincrement fields with DbxSda? Do you have to manually specify the Field.AutoGenerateValue to arAutoInc?

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

Post by Ikar » Tue 18 Oct 2005 14:03

Due to dbExpress technology limitations we can't return isAutoIncrement flag for such fields.

99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

Post by 99Percent » Wed 02 Nov 2005 17:23

I am trying to use the autoincrement feature of the column.

During an insert does your driver send a null value for this column when arAutoInc is specified and get the actual value from the server after the insert?

I can't get it to work this way. I specify arAutoInc at the TSQLDataSet.Field object do I need to specify it also at the ClientDataSet level?

99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

Post by 99Percent » Wed 02 Nov 2005 21:02

Never mind I had forgotten to set the identity property at the table design on the server :oops:

Post Reply