Problem with Identity field in MSQuery

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Dimonis
Posts: 2
Joined: Fri 21 Dec 2007 09:19

Problem with Identity field in MSQuery

Post by Dimonis » Fri 21 Dec 2007 09:29

Delphi 6 – MS SQL Server 2000 – SDAC 4.3.0.13

Hi. I have table that has created with Script:

Create Table Istrab (
ID_Istrab BigInt Identity(1,1) not null, -- ID èñòîðèè "ðàáîòàåò
Fio_GUID Varchar(38) null, -- GUID êëèåíòà
Kodsost Tinyint null, -- êîä ñîñòîÿíèÿ
Dhom Datetime null, -- äàòà íà÷àëà "ðàáîòàåò"
Dend Datetime null, -- äàòà êîíöà "ðàáîòàåò"
)
Create NonClustered Index Istrab_ID On Istrab(ID_Istrab)

For access to this table uses MSQuery (has name Rabuc) that placed properties:

SQL:
Select ID_Istrab, Fio_GUID, Kodsost, Dhom, Dend From Istrab Where Istrab.Fio_GUID=:p1
Order by Istrab.ID_Istrab

SQLDelete:
DELETE FROM Istrab WHERE ID_Istrab=:Old_ID_Istrab

SQLInsert:
INSERT INTO Istrab (Fio_GUID, Kodsost, Dhom, Dend) VALUES (:Fio_GUID, :Kodsost, :Dhom, :Dend)

SQLRefresh:
Select ID_Istrab, Fio_GUID, Kodsost, Dhom, Dend,
Forist.NaimForist
From Istrab left join Forist on Istrab.Kodsost=Forist.Kod
Where ID_Istrab=:ID_Istrab

SQLUpdate:
UPDATE Istrab
SET Kodsost=:Kodsost, Dhom=:Dhom, Dend=:Dend
WHERE ID_Istrab=:ID_Istrab

Application has Code:
Rabuc.Insert;
RabucFio_GUID.Value:=’18’
Rabuc.Post;

After execute this code application say that RabucFio_GUID.AsString is ‘18’ but RabucID_Istrab.AsString=’0’ in inserted record.

I have a question – how can make that after Insert in application can see Identity field.

Thanks.

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

Post by Antaeus » Fri 21 Dec 2007 16:22

A similar question was recently discussed at this thread. Please take a look at it.

Post Reply