Board index » delphi » Insert record in MS SQL through Delphi

Insert record in MS SQL through Delphi

Hi!

I've a problem with a property of a field IDENTITY.

I make a field in my database
ID integer IDENTITY(1,1) PRIMARY KEY CLUSTERED,
....

Write code

 Tbl.Insert;
 TblField1.Value := 1;
  Tbl.Post; ===> Exception - "The field "ID" must have a value"

 Set property Required = False of field ID

try
 Tbl.Insert;
 TblField1.Value := 1;
 Tbl.Post; ===> Exception - "The field "ID" must have a value"
except
 on EDataBaseError do Tbl.Post;
end;

My program dosen't message exception, but a flield TblID.Value equal to
zero after
inserting, although there's field ID is not null in my database.

What's my fault? Someone must have decided this problem, because it isn't
to
work with relations MS SQL.

                                hans.mtbank.ru

 

Re:Insert record in MS SQL through Delphi


What version of MSSQL are you using?  There is a technical document on the
Borland/Delphi website (http://www.borland.com ) which deals with posting
records to MSSQL 6.0 and earlier when using an identity field.  Check that
document out and see if that helps.

David Sweeney
adapti...@tamu.edu

Kolenyko Sergey <h...@mtbank.ru> wrote in article
<01bca0a5$bc53fc80$164f5...@hans.mtbank.ru>...

Quote
> Hi!

> I've a problem with a property of a field IDENTITY.

> I make a field in my database
> ID integer IDENTITY(1,1) PRIMARY KEY CLUSTERED,
> ....

Other Threads